淡漠世俗 2021-08-04 15:05 采纳率: 0%
浏览 24

kotlin+JPA+hibernate使用@query查询

(HQL,JPQL,原生SQL等)这是什么查询语句?希望能提供个网址详细学习


package com.umh.doctorreferral.core.model.doctorreferralcase

import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param
import java.util.*

interface DoctorReferralCaseRepository : JpaRepository<DoctorReferralCase, UUID> {

    @Query(value = """
        select t
            from DoctorReferralCase t
            where (t.status <> 'DRAFT' or t.status is null)
            and 
            ( :#{ #referralCase.referralDate} is null or t.referralDate >= to_date(:#{ #referralCase.referralDate }, 'yyyy-mm-dd')   )
            and 
            ( :#{ #referralCase.fromDoctor} is null or t.fromDoctor = :#{ #referralCase.fromDoctor } )
            and 
            ( :#{ #referralCase.toDoctor} is null or  t.toDoctor = :#{ #referralCase.toDoctor })
            and 
            ( :#{ #referralCase.referralType} is null or t.referralType = :#{ #referralCase.referralType }  )
            and 
            ( :#{ #referralCase.status} is null or t.status = :#{ #referralCase.status } )
    """)
    fun pageReferralCase(@Param("referralCase") param : ReferralCasesSearchParam, pageable: Pageable) : Page<DoctorReferralCase>

}

  • 写回答

1条回答 默认 最新

  • CSDN专家-微编程 2021-08-04 15:15
    关注

    你这个query查询,表就是对应的实体类,字段名对应的就是属性,如果你想用原生的sql,在query里面添加nativeQuery = true,就可以了,你可去B站进行相关的jpa学习

    评论

报告相同问题?

问题事件

  • 创建了问题 8月4日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘