SprintBoot学习笔记004(dao层jpa接口)
来源:互联网 发布:java项目目录结构 编辑:程序博客网 时间:2024/06/06 18:43
源码地址:http://download.csdn.net/download/u010503822/10020714
注明:该内容来自Andy讲师视频整理
Repository接口
是个springdata的核心接口,它不提供任何方法,开发者需要在自己定义的接口中什么需要的方法
源码:
public interface Repository<T, ID extends Serializable> {
注意:
1.Repository接口是个空接口,标记接口
2.如果定义的接口继承Repository,会被ioc容器识别
3.实际可以通过@RepositoryDefinition注解来代替继承Repository接口
4.查询方法以find|read|get开头(比如getBy findBy)
5.涉及查询条件,条件的属性用条件关键字连接,注意,条件属性以首字母大写
6.使用@Query注解定义JPQL语句实现更灵活的查询。
源码:
@NoRepositoryBean public interface CrudRepository<T, ID extends Serializable> extends Repository<T, ID> { <S extends T> S save(S var1); <S extends T> Iterable<S> save(Iterable<S> var1); T findOne(ID var1); boolean exists(ID var1); Iterable<T> findAll(); Iterable<T> findAll(Iterable<ID> var1); long count(); void delete(ID var1); void delete(T var1); void delete(Iterable<? extends T> var1); void deleteAll();
PagingAndSortingRepository接口
该接口提供分页和排序
源码:
@NoRepositoryBean public interface PagingAndSortingRepository<T, ID extends Serializable> extends CrudRepository<T, ID> { Iterable<T> findAll(Sort var1); Page<T> findAll(Pageable var1); }
其他接口
JpaRepository:差所有实体,排序,查所有实体,执行缓存和数据库同步
JpaSpecificationExecutor 不属于Repository层,实现一组jpa Criteria查询相关的方法,封装jpa Criteria查询条件 通过使用匿名内部类的方式来创建该接口的对象自定义 Repository:可自己定义一个MyRepository接口
阅读全文
0 0
- SprintBoot学习笔记004(dao层jpa接口)
- SprintBoot学习笔记(1):创建SpringBoot
- SprintBoot学习笔记(3):简单登录功能
- SprintBoot学习笔记(4):登录(Hibernate+Mysql)
- DAO层接口定义多个入参(Mybatis)
- JPA学习笔记(2)之相关接口/类
- SprintBoot学习笔记(2):SpringBoot跳转至页面
- SprintBoot学习笔记(5):解决中文乱码问题
- SSH中公共Dao层、Dao接口
- Hibernate-DAO层接口理解
- JAVA学习笔记(五十二)- 开发DAO层的经典实现
- MyBatis学习笔记-Spring集成DAO层实现方式记录
- 分层学习(dao接口及实现)
- JPA学习笔记(转)
- JPA学习笔记(一)
- JPA学习笔记(一)
- JPA学习笔记(二)
- JPA学习笔记(三)
- <base href="<%=basePath%>">作用
- Java接口回顾
- CSS样式引入方式和部分CSS样式的设置
- 树莓派使用ubuntu mate
- 闭包的运用-点赞-计数器
- SprintBoot学习笔记004(dao层jpa接口)
- 计数排序
- 九度OJ——1201二叉排序树
- Tensorflow基础:模型持久化
- 日期+序列构建系统唯一序列号(二)
- QT(1):空工程建立程序方式与文本建立程序方式的运行
- flask 的url_for
- 大数据算法面试题
- inline关键字