I read the section on custom implementation and my issue is that this customization detection is intrusive.
Entity:
Code:
@Entity
@NamedQueries({ @NamedQuery(name = "MyEntity.findAllIds", query = "select id from MyEntity") })
public class MyEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
public Long getId() {
return id;
}
}
The DAO (first version):
Code:
public interface MyDAO
extends JpaRepository<MyEntity, Long> {
Set<Long> findAllIds();
}
In this configuration everything is working fine (at least from the nightly build) thanks to the named query in the entity.
Now I want to make MyDAO a child of the following interface:
Code:
@NoRepositoryBean
public interface BaseDAO {
Set<Long> findAllIds();
}
So I change MyDAO to the following form:
Code:
public interface MyDAO
extends BaseDAO, JpaRepository<MyEntity, Long> {
}
I commented removed the findAllIds method as it is already defined in BaseDAO.
In this case I get the following error at runtime:
Code:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myDAO': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: You have custom methods in interface test.MyDAO but not provided a custom implementation!
[snip]
Caused by: java.lang.IllegalArgumentException: You have custom methods in interface test.MyDAO but not provided a custom implementation!
at org.springframework.data.repository.support.RepositoryFactorySupport.validate(RepositoryFactorySupport.java:226)
at org.springframework.data.repository.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:130)
at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:107)
at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:36)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 9 more
Of course I can workaround this by keeping the findAllIds declaration in both BaseDAO and MyDAO but this is definitely redundant and error prone.