請問使用springData的方式。怎么做通用DAO?泛型會報錯。
不可能每個實體需要一個空的接口來繼承CrudRepository吧?所以我想用泛型代替:
public class Dao extends CrudRepository<T,D exteds Serializable>
在Service層直接使用: Dao<User,Integer> dao;
但是這樣,會報錯,不知道老師有什么解決辦法嗎?
不可能每個實體需要一個空的接口來繼承CrudRepository吧?所以我想用泛型代替:
public class Dao extends CrudRepository<T,D exteds Serializable>
在Service層直接使用: Dao<User,Integer> dao;
但是這樣,會報錯,不知道老師有什么解決辦法嗎?
2017-10-22
舉報
2019-08-26
https://docs.spring.io/spring-data/jpa/docs/1.11.3.RELEASE/reference/html/#repositories.custom-behaviour-for-all-repositories
可以參考一下