Skip to content
Advertisement

Tag: spring-data-jpa

How to set a specific DataSource for a Repository?

Is it possible to assign a specific DataSource to a @Repository? I’d like to create a test environment where in general I want to use the test-datasource, but a few CrudRepository should operate on a different DB (the production DB; read-only operations). Can I tell spring which datasource to use for a repository explicit? public interface MyRepository extends CrudRepository<Customer, Long>

%Like% Query in spring JpaRepository

I would like to write a like query in JpaRepository but it is not returning anything : LIKE ‘%place%’-its not working. LIKE ‘place’ works perfectly. Here is my code : Answer The spring data JPA query needs the “%” chars as well as a space char following like in your query, as in @Query(“Select c from Registration c where c.place

How to implement only specific method of CrudRepository in Spring?

I’m using CrudRepository of spring-data-jpa to just define an interface of an entity and then having all standard crud methods without having to provide an implementation explicitly, eg: Though now I’d like to override only the save() method in my custom implementation. How could I achieve this? Because, if I implement the interface UserRepo, I’d have to implement all other

Query creation in Spring Data – dynamic where clause

Is there a way in Spring data to dynamically form the where clause? What I want to do is have a method (which is like the findBy / get method) which runs a WHERE and AND using the mentioned properties which are NOT NULL. For example, Our method looks something like this Thanks. Answer Take a look at JPA Specification

What is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?

What is the difference between CrudRepository and JpaRepository interfaces in Spring Data JPA? When I see the examples on the web, I see them there used kind of interchangeably. What is the difference between them? Why would you want to use one over the other? Answer JpaRepository extends PagingAndSortingRepository which in turn extends CrudRepository. Their main functions are: CrudRepository mainly

Advertisement