简体   繁体   English

Spring Data JPA中的通用Crud

[英]Generic Crud in 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 : 所以我像这样使用spring data jpa

 public interface SecteurAlerteRepository extends 
     JpaRepository<SecteurAlerte, Integer>, QueryDslPredicateExecutor<SecteurAlerte>
     { }

But i have to cretae a lot of interface about 50 ones and it's too much !! 但是我必须创建大量约50个的界面,而且太多了!

there is not a generic way to use just standard query CRUD in Spring data or in a other way ? 有没有通用的方法可以仅在Spring数据中或以其他方式使用标准查询CRUD?

There is no way to do this in Spring Data. 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. Spring Data的内部机制需要接口定义中的类型参数,如果没有带有特定类型参数的接口定义,则只能使用类型参数的边界(如果有疑问,则为Object ),这是不可用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM