Spring Boot Jpa如何封装一个BaseDao?
怎么把springboot的jpa封装一个basedao,
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>
其他的dao,都继承这个BaseDao就可以呢?
而不是每一个Dao都继承JpaRepository这个。
比如:
public interface DepartmentDao extends JpaRepository<Department, Integer>, JpaSpecificationExecutor<Department>
这样正确
但是,如果public interface DepartmentDao extends BaseDao<Department, Integer>
就错误。
错误如下:
Error creating bean with name 'departmentDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property createObject found for type Department!
应该怎么写呢?
请大神帮忙!
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>
其他的dao,都继承这个BaseDao就可以呢?
而不是每一个Dao都继承JpaRepository这个。
比如:
public interface DepartmentDao extends JpaRepository<Department, Integer>, JpaSpecificationExecutor<Department>
这样正确
但是,如果public interface DepartmentDao extends BaseDao<Department, Integer>
就错误。
错误如下:
Error creating bean with name 'departmentDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property createObject found for type Department!
应该怎么写呢?
请大神帮忙!
...全文
相关推荐
SpringBoot_BaseDao.zip
尊重原创——SpringBoot_BaseDao.zip,内部含有反射,获取泛型类类型,如何使用等,自己下载查看
framework:基于spring-boot和ExtJS的权限管理和基础架构
基于spring-boot和ExtJs的权限管理和基础架构 com.adoph.framework algorithm 算法 sort.SortUtils.java 简单排序工具类 +++++++++++++++++++++++++++++++++++++++++++ core 框架核心 core.cache 缓存封装 lock 锁 DistributedLockManager.java 基于Redis的分布式锁 +++++++++++++++++++++++++++++++++++++++++++ dao.jpa 基于JPA封装BaseDao +++++++++++++++++++++++++++++++++++++++++++ exception 异常 bean 异常相关bean Error.java 错误消息 handler 异常handler WebExceptionHandler
spring hibernate整合的底层数据操作方法
spring hibernate整合的底层数据操作方法,提供增删改查等通用方法
Java Web 是指使用 Java 技术栈来开发 Web 应用程序
Java Web 是指使用 Java 技术栈来开发 Web 应用程序
基于泛型的通用Dao接口和hibernate的实现
基于泛型的通用Dao接口和hibernate的实现


Web 开发
