본문 바로가기
728x90
반응형

JPA4

[Spring Data JPA] jpql(@Query)이 동작하지 않을때, No property / Did you mean error Spring Data JPA에서 No property 'ids' found for type 'entity' Did you mean ''name','id''와 같이 No property, found for type, Did you mean이 발생하면서 jqpl이 작동하지 않는다. 아무리 찾고 수정해도 코드나 로직에 문제가 없었기에 개발 일정 중 하루를 낭비했다 - 결론은 import를 잘못해서 발생한 오류였음 - 해결 방법 오류발생한 import import org.springframework.data.jdbc.repository.query.Query; 아래 import로 변경 import org.springframework.data.jpa.repository.Query; 같은 스프링프레임워크의 Query.. 2023. 3. 9.
[JPA] Specification 사용자 정의 함수 사용 JPA에서 Specification으로 사용자 정의 함수 where절 조건 검색하기 ### Specification public static Specification nameLike(String text) { return (root, query, cb) -> { Expression nameExpr = cb.function("fn_usrNm", String.class, root.get("name")); return cb.like(nameExpr, "%" + text + "%"); }; } 1. 사용자 정의 함수(sql function) 1개의 조건일 경우 #### Service Specification spec = Specification.where(EntitySpec.nameLike(text)); 2. .. 2023. 3. 7.
JPA native Query count 방법 JPA nativeQuery 사용시 Page 타입으로 받기위해서 count 가져오는법 @Query(value = "SELECT c.ID AS id, c.USR_GRP_ID AS usrGrpId, c.USR_ID AS usrId, c.CONTENT AS content " + "FROM BOARD c " + "LEFT JOIN STD_USR_GRP g ON c.USR_GRP_ID = g.USR_GRP_ID " + "LEFT JOIN STD_USR u ON c.USR_ID = u.USR_ID " + "WHERE 1=1 " + "AND c.CREATED BETWEEN :startDate AND :endDate " + countProjection = "ID", nativeQuery = true) Page find.. 2023. 3. 2.
DATA JPA 사용자 정의 함수 사용하기 , Dialect 정의 방법 DB : MSSQL / SQL Server data jpa 사용자 정의 함수 사용하기 #application.properties spring.jpa.properties.hibernate.show_sql=true spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.dialect=com.smple.service.admin.hibernate.dialect.SQLServerDialect -- 사용자 정의 함수가 정의된 dialect java 파일의 경로를 정의합니다 #Dialect public class SQLServerDialect extends SQLServer2012Dialect { public SQLServerDi.. 2023. 3. 2.
728x90
반응형