Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic code failed with Spring data and Querydsl

i use querydsl that's why i don't need method like findByName() and all my repository interface are empty.

So i try to make genric code to avoid repetitive interface with empty methods because i have many classes in my entities mapped by hibernate.

public interface GenericResposotory<T> 
              extends JpaRepository<T, Integer>, QueryDslPredicateExecutor<T> {

}

When I run my server I get this error :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericResposotory': 
Invocation of init method failed; nested exception is 
java.lang.IllegalArgumentException: Not an managed type: class java.lang.Object

also there is not a way to make a generic repository like i try to do ?

like image 709
Hayi Avatar asked Nov 21 '14 06:11

Hayi


1 Answers

Spring data tries to create beans for all interfaces you create that extend JpaRepository. If you want to have a kind of base repository that will not be used mark your interface with @NoRepositoryBean

like image 154
Nadir Avatar answered Nov 18 '22 02:11

Nadir