필요 캐스트 왜! 작은 응용 프로그램을위한 프레임 워크. 모델에서 나는 다음과 같은 쿼리가 :하이버 네이트 JPQL 유형이 문자열
public static ApplicationUser getByUserName(String userName) {
return ApplicationUser.find("SELECT u FROM ApplicationUser u WHERE u.userName = ?", userName).first();
}
이 메모리 DB H2에서 완벽하게 작동하지만 내가 포스트 그레스를 사용할 때 다음과 같은 오류를 얻을 : 내가 좋아하는 매개 변수를 캐스팅
22:57:10,371 WARN ~ SQL Error: 0, SQLState: 42883
22:57:10,371 ERROR ~ ERROR: operator does not exist: character varying = bytea
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Position: 167
:
ApplicationUser.find("SELECT u FROM ApplicationUser u WHERE u.userName = CAST(? AS string)", userName).first()
그러면 작동합니다. 그러나 이것이 필요한 이유는 무엇입니까? 그것은 최대 절전 모드 버그 일 수 있습니까?
업데이트 : 재생 버전을 1.2.4에서 1.2.3으로 다운 그레이드하여 이제는 작동합니다. 나는 문제가 아마도 제공 포스트 그레스 JDBC 드라이버에있다 생각합니다.
업데이트 II : 문제는 여전히 해결되지 않습니다. 나는 쿼리에 대해 다시 같은 오류가 발생합니다 :
ApplicationRole.find("byName", name).first();
오류 : application.conf
에서
JPAQueryException occured : Error while executing query SELECT u FROM ApplicationUser u WHERE u.userName = ?: ERROR: operator does not exist: character varying = bytea Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
내가 가진 :
jpa.dialect=org.hibernate.dialect.PostgreSQLDialect
아무도이 오류가없는?
. 1.2.4에서 1.2.3으로 플레이를 다운 그레이드했습니다. 이제 모든 것이 정상적으로 작동합니다. – reen
그것은 지금 나를 도왔다. 감사. 늦은 답변 죄송합니다 – reen