![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Spring Data
weixin_39102174
这个作者很懒,什么都没留下…
展开
-
在引入JPA依赖时,"spring-boot-starter-data-jpa" 与 "spring-data-jpa" 的区别
starter是spring-boot的项目,包含了spring-data-jpa和一些其他依赖用于spring-boot项目data-jpa是spring-data的项目,就是本体,用于任何项目转载 2019-11-22 15:24:16 · 1131 阅读 · 0 评论 -
SpringData之Repository Populators的使用
需要用到Jackson或者JAXB1. Jackson依赖引入:<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> ...原创 2019-11-21 16:02:43 · 229 阅读 · 0 评论 -
SpringData自定义分页查询
repository:public interface MyRepository extends CrudRepository<TestPerson,Integer>, QuerydslPredicateExecutor<TestPerson> {}controller: @RequestMapping(value = "/test2") @...原创 2019-11-18 16:24:23 · 152 阅读 · 0 评论 -
SpringData之webSupport
1.配置@Configuration@EnableWebMvc@EnableSpringDataWebSupportclass WebConfiguration {}2.controller @RequestMapping("/{id}") TestPerson showUserForm(@PathVariable("id") TestPerson user...原创 2019-11-18 16:23:20 · 196 阅读 · 0 评论 -
QueryDSL初探及在SpringData中的使用
QueryDSL是一个通用的查询框架,专注于Java API构建类型安全的SQL查询。1.idea引入相关依赖 <dependency> <groupId>com.querydsl</groupId> <artifactId>querydsl-jpa</artifactI...转载 2019-11-18 14:19:21 · 572 阅读 · 0 评论 -
Spring Data相关(二)之自定义接口
一、自定义接口方法1.自定义Spring data接口public interface CustomizedUserRepository { //自定义方法 void someCustomMethod(TestPerson person);}自定义接口实现类:public class CustomizedUserRepositoryImpl implemen...原创 2019-11-06 17:02:22 · 194 阅读 · 0 评论 -
SpringData之Streamable和Stream简单区别
1.使用Stream时必须使用类似于@Transactional等关闭资源 @RequestMapping(value = "/test26") @ResponseBody @Transactional public void test26(){ PageRequest pageRequest=PageRequest.of(0,10); ...原创 2019-10-17 15:44:16 · 2067 阅读 · 0 评论 -
SpringData之@NonNullApi、@NonNull、@Nullable
1.@NonNullApi 包级别注释package-info.java中使用@org.springframework.lang.NonNullApi/** * 包注释、包文档 */package com.pactera.workflow.entity.test;2.@NonNull 方法级别和参数级别3.@Nullable方法级别和参数级别若使用了@NonNull...原创 2019-10-10 14:17:53 · 2157 阅读 · 0 评论 -
SpringData限制表达式之Top、First使用
Top和First可以互换使用。public interface MyRepository extends Repository<TestPerson,Integer> { Slice<TestPerson> findAllByNameLike(String name,Pageable pageable); Page<TestPerson>...原创 2019-10-10 10:24:16 · 930 阅读 · 1 评论 -
PageRequest方法过时
//方法一 Pageable pageable=new PageRequest(0,5); //方法二 Pageable pageable1=PageRequest.of(1,4);方法一会提示已经过时,可用方法二替代转载 2019-10-09 16:33:19 · 3196 阅读 · 4 评论 -
SpringData分页Page、Slice、Pageable用法
1.返回list List<TestPerson> findByNameLike(String name);2.返回org.springframework.data.domain.PagePageable pageable1=PageRequest.of(1,4); Page<TestPerson> slice4=myRepository.q...转载 2019-10-09 16:31:38 · 4349 阅读 · 0 评论 -
SpringData模糊查询用法
1.方式一:controller层处理public interface MyRepository extends Repository<TestPerson,Integer> { Slice<TestPerson> findAllByNameLike(String name,Pageable pageable); List<TestPerson...转载 2019-10-09 15:57:13 · 490 阅读 · 0 评论 -
JPA中为Entity添加自定义类
使用@Embeddable和@Embedded注解实现效果是在tb_test_person中,Address类的字段解析成表字段。import javax.persistence.*;@Entity(name = "tb_test_person")public class PersonEntity { @Column(name = "ID_") @Id ...转载 2019-09-24 17:49:41 · 679 阅读 · 0 评论 -
Spring Data 相关(一)
1.JpaRepository或MongoRepository继承于CrudRepository,CrudRepository继承于Repository2.PagingAndSortingRepository继承CrudRepository3.//ID是entity类T中ID的数据类型public interface TestJpa extends JpaRepository<...原创 2019-09-23 17:50:31 · 80 阅读 · 0 评论