Spring Data Spring Data JPA Hello World Repository
- Slides: 39
Spring. Data 概述
Spring. Data JPA Hello. World
Repository 接口
Spring. Data 方法定义规范
索引参数与命名参数 • 如果是 @Query 中有 LIKE 关键字,后面的参数需要前 面或者后面加 %,这样在传递参数值的时候就可以不加 %: – @Query("select o from User. Model o where o. name like ? 1%") public List<User. Model> find. By. Uuid. Or. Age(String name); – @Query("select o from User. Model o where o. name like %? 1%") public List<User. Model> find. By. Uuid. Or. Age(String name);
用@Query来指定本地查询 • 还可以使用@Query来指定本地查询,只要 设置native. Query为true,比如: – @Query(value="select * from tbl_user where name like %? 1" , native. Query=true) public List<User. Model> find. By. Uuid. Or. Age(String name);
@Modifying 注解和事务
Crud. Repository 接口
Crud. Repository • Crud. Repository 接口提供了最基本的对实体类的添删改查操作 – T save(T entity); //保存单个实体 – Iterable<T> save(Iterable<? extends T> entities); //保存集合 – T find. One(ID id); //根据id查找实体 – boolean exists(ID id); //根据id判断实体是否存在 – Iterable<T> find. All(); //查询所有实体, 不用或慎用! – long count(); //查询实体数量 – void delete(ID id); //根据Id删除实体 – void delete(T entity); //删除一个实体 – void delete(Iterable<? extends T> entities); //删除一个实体的集合 – void delete. All(); //删除所有实体, 不用或慎用!
Paging. And. Sorting. Repository接口
Paging. And. Sorting. Repository • 该接口提供了分页与排序功能 – Iterable<T> find. All(Sort sort); //排序 – Page<T> find. All(Pageable pageable); //分页查询 (含排序功能)
Jpa. Repository接口
Jpa. Repository • 该接口提供了JPA的相关功能 – List<T> find. All(); //查找所有实体 – List<T> find. All(Sort sort); //排序、查找所有实体 – List<T> save(Iterable<? extends T> entities); //保存 集合 – void flush(); //执行缓存与数据库同步 – T save. And. Flush(T entity); //强制执行持久化 – void delete. In. Batch(Iterable<T> entities); //删除一个 实体集合
Jpa. Specification. Executor接口
属性的属性 name 属性 contact Customer 实体类:Root
实际上在使用 Person. Repository 的 test 方 法时,会调用 Person. Repository. Impl 中 test 方法的实现
- Hello good morning what's your name jenny
- The greetings song
- Whats your name bob
- Crudrepository
- Hello my friend!
- Hello everyone i hope you are doing well
- Birchfield nursery
- Hello my friend friend of a friend
- Hello good evening hi
- Nanny shine has got
- Hello hello to everyone it's english time
- Hello hello 1 2 3
- Hello i am muzzy
- Hellopt
- Peter pan hello song
- Meditech dr
- Mghs wheelers
- Dryad data repository
- Clinical data repository
- Dryad data submission
- Open science framework data repository
- Integrated data repository
- Ucl data repository
- Integrated data repository
- Geothermal data repository
- Bae yong-kyun
- Summer winter autumn spring
- Sara ubat jpa
- Borang sara ubat jpa
- Saraubat jpa
- Kenaikan pangkat secara fleksi
- Jpa weak entity
- Jpa.bp.spt.b03a
- Jpa pasca perkhidmatan
- Pelan exit policy pekerja asing
- Dali java persistence tools
- Borang jpa (epw)
- Pencen jpa
- Akrab care
- Carta proses q