春季资料jpa中的通用Crud [英] Generic Crud in spring data jpa
问题描述
我有很多的表,其中几乎我只是保存或删除它们,而无需另一个查询。
因此,我使用 spring data jpa
像这样:
I have a lot of tables and almost of them i have just to save or delete them without another query.
So I use spring data jpa
like this :
public interface SecteurAlerteRepository extends
JpaRepository<SecteurAlerte, Integer>, QueryDslPredicateExecutor<SecteurAlerte>
{ }
但是我必须创建大量的大约50个界面,很多!
But i have to cretae a lot of interface about 50 ones and it's too much !!
在Spring数据或其他方式中没有使用标准查询CRUD的通用方法吗?
there is not a generic way to use just standard query CRUD in Spring data or in a other way ?
推荐答案
在Spring Data中没有办法做到这一点。 Spring Data的内部机制需要来自接口定义的类型参数,并且如果不存在具有特定类型参数的接口定义,则只有类型参数( Object )怀疑)是不可用的。
There is no way to do this in Spring Data. The inner mechanics of Spring Data need the type parameters from the interface definition and if there is no interface definition with specific type parameters only the bound of the type parameters (Object
in case of doubt) is available which is not usable.
这篇关于春季资料jpa中的通用Crud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!