永続性プロバイダーとしてHibernateでSpringDataJPAを使用しています。PostgreSQL9.1.5は私のデータベースです。
クエリ:
@Query("select COUNT(u) from User u where u.enabled=true")
自動的に翻訳されます
select count(user0_.username) as col_0_0_ from users user0_ where user0_.enabled=1
ご覧のとおり、「true」は「1」に置き換えられています。Postgreはこのクエリを受け入れず、エラーがスローされます。
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select count(user0_.username) as col_0_0_ from users user0_ where user0_.enabled=1]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query] with root cause
置換なしのクエリは正常に機能します。pgadminクエリインターフェイスでは、次のクエリが機能します。
select count(user0_.username) as col_0_0_ from users user0_ where user0_.enabled=true
この問題を解決するにはどうすればよいですか?