Linked Questions
21 questions linked to/from Using generics in Spring Data JPA repositories
0 votes
1 answer
4k views
Trouble with Generic Repository in Spring Data JPA [duplicate]
I'm trying to do some basic database operations using a generic repository in Spring Data JPA. However, I keep running into an IllegalArgumentException "Not an managed type: " + whatever class/...
3 votes
1 answer
4k views
How to use generics with JpaRepository of spring data jpa [duplicate]
//generic repo public interface MyGenericRepo extends JpaRepository<GenericEntity,Integer> { } //entity class Place extends GenericEntity { private Event event; } //entity class Event ...
12 votes
1 answer
17k views
How to implement Generic JPA Repository in Spring Boot - Which can be autowired into spring services for any entity/class type
Here is the sample Generic Repository implementation which extends the spring PagingAndSortingRepository, @NoRepositoryBean public interface GenericRepository<T, ID extends Serializable> ...
3 votes
3 answers
7k views
Spring dynamic JPA repository type
I have about 30 tables that I need to fill from an XML file. And I want to use JPA for that purpose. Now I have 30 classes annotated with @Entity, config that scans entities and repositories; Also I ...
3 votes
2 answers
5k views
Generic Repository in Spring JPA
We are working on a Restful project with lots of DB tables. Though the operations on the tables are almost same and mainly INSERT/UPDATE/DELETE/FETCH. my questions is: will we have to create a ...
3 votes
2 answers
28k views
Generic Spring Data JPA Repository findAll
Is there a way to make a generic Spring Data JPA repository handle correctly methods like findAll()? e.g. AnimalRepository<Dog>.findAll return only Dogs, instead of all animals? Or at least, how ...
4 votes
2 answers
10k views
JPA repository with single table inheritance (hibernate)
I have created two entites (RegularEmployee and ContactEntity) that extends the Employee entity. @Entity @Table(name="employees") @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @...
1 vote
1 answer
4k views
Spring JPA Data Repository: How to create a generic repository? [closed]
I've been searching for a way to do this but can't quite find it. Basically I'd like to make a generic repository I can inject anywhere. I have lots of cruds I need to make in this project and they ...
5 votes
1 answer
3k views
How do I reuse a parameter witha Spring-Data-JPA Repository?
In looking at the Query Creation for the Spring Data JPA Repositories, I'm wondering how I would reuse a parameter. For example, how would I name the method if I wanted to do something like: @Query("...
0 votes
2 answers
5k views
How to create one crudrepository for multiple entity and multiple @query in single repo
I want something just like this...i know someone will get it what i want public interface PersonneRepo extends JpaRepository<T, Long> { @Query("Select p.name, p.surname, p.age, p.city, p....
3 votes
2 answers
2k views
Is it possible to create common JpaRepository Interface?
I have created an interface like this, @Repository public interface IJpaRepositoryCustom<T> extends JpaRepository<T,Long>{ } And service class @Service public class LOVService<T>{ ...
0 votes
1 answer
2k views
How to get data from a table by entity class name using Spring Data JPA
I have a base entity class BaseDictionary: @Entity @Inheritance public abstract class BaseDictionary { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.IDENTITY) ...
2 votes
1 answer
1k views
Spring data repository and DAO Java Generics
Reading about using Java Generics in DAO layer, I have a doubt applying this in spring data repositories. I mean, with spring data repositories, you have something like this: public interface ...
0 votes
1 answer
1k views
Generics and Spring Data JPARepository
This is a follow-up question based on Oliver Gierke's suggestion. We have two tables (almost same information) but for some external reasons, cannot use a common single table. I am getting an error ...
0 votes
1 answer
1k views
JPA Repository find by param generic method
I have a generic interface that extends the JpaRepository, I've overridden some methods and I want to create a new generic method to find records by field name and its value. e.g : @Query("SELECT ...