SpringData

SpringData

Spring Data存储库抽象的目标是显着减少为各种持久性存储实现数据访问层所需的样板代码量。

Spring Data存储库抽象中的中央接口是Repository。它将域类以及域类的ID类型作为类型参数进行管理。此接口主要用作标记接口,用于捕获要使用的类型,并帮助您发现扩展此接口的接口。(CrudRepository, PagingAndSortingRepository)

Querydsl

使用Querydsl支持,Repository需继承QuerydslPredicateExecutor

interface UserRepository extends CrudRepository<User, Long>, QuerydslPredicateExecutor<User> {
}

需引入依赖

<dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-jpa</artifactId>
    <version>${querydsl.version}</version>
</dependency>

<dependency>
    <groupId>com.querydsl</groupId>
    <artifactId>querydsl-apt</artifactId>
    <version>${querydsl.version}</version>
</dependency>

添加插件

<plugin>
    <groupId>com.mysema.maven</groupId>
    <artifactId>apt-maven-plugin</artifactId>
    <version>1.1.3</version>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>process</goal>
            </goals>
            <configuration>
                <outputDirectory>target/generated-sources/java</outputDirectory>
                <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
        </execution>
    </executions>
</plugin>

文章作者: the next page
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 the next page !
评论
 上一篇
LDAP学习与介绍 LDAP学习与介绍
概念LDAP是轻量目录访问协议(Lightweight Directory Access Protocol)的缩写,其结构用树来表示,而不是用表格。它有优异的读性能,但写性能差,并且没有事务处理、回滚等复杂功能,不适于存储修改频繁的数据。
2019-04-04 the next page
下一篇 
springsecurity参考手册 springsecurity参考手册
创建java配置 1.使用@EnableWebSecurity 注解启用Web安全功能 2.创建类SecurityConfiguration继承WebSecurityConfigurerAdapter,来对应用中所有的安全相关的事项(所有u
2019-03-30 the next page
  目录