Tag: 弹簧数据JPA

Spring Data JPA仍然试图为自定义实现生成一个查询方法

我目前使用Kotlin 1.2和Spring Boot 2.0 M7和Spring Data JPA 2.0.2。 在这里我试图创建一个自定义实现的存储库。 我的参考是这个https://docs.spring.io/spring-data/jpa/docs/2.0.2.RELEASE/reference/html/#repositories.custom-implementations 这是回购 interface DailyBuildStatusRepository : BaseRepository, DailyBuildStatusCustomRepository { } 这是接口片段 interface DailyBuildStatusCustomRepository { fun filter(product: Int?, branch: Int?, correction: Int?, globalSearch: String, isRegEx: Boolean, columnParams: Collection, start: Int, length: Int): List } 这是实现类的骨架 @Repository class DailyBuildStatusCustomRepositoryImpl : DailyBuildStatusCustomRepository { @Autowired private val em: EntityManager? = null […]

Kotlinic模式使用Spring Data JPA的“查询范例”

Spring Data JPA引入了一个很好的function,即“通过示例查询”(QBE) 。 您通过构建实体的实例来expression您的搜索条件。 您不必编写JPQL。 它比存储库查询派生使用更少的“魔术”。 语法很好。 它防止琐碎的存储库代码的爆炸。 它很好地重构了重构。 但有一个问题:只有部分构建对象时,QBE才能正常工作。 这是我的实体: @Entity @Table(name=”product”) data class Product( @Id val id: String, val city: String, val shopName: String, val productName: String, val productVersion: Short ) 这里是我的存储库(空的!这是关于QBE的一件好事): @Repository interface ProductRepository : JpaRepository 以下是您如何获取List – 某些商店中某些城市销售的所有产品: productRepository.findAll(Example.of(Product(city = “London”, shopName=”OkayTea”))) 或者至少,这就是我想要做的。 有一个问题。 这是不可能的 : Product(city = “London”, shopName=”OkayTea”) […]