0

The error I get:

ERROR 42821: Columns of type 'BOOLEAN' cannot hold values of type 'INTEGER'.

For the JPQL query:

SELECT b.id FROM Bar b WHERE b.latest = true

Apparently because Hibernate maps a Boolean field (ie "latest) to an integer column for JavaDB/Derby. But this only happens when the column is accessed in JPQL. Same result when using the Criteria API.

Hibernate has been set to org.hibernate.dialect.DerbyDialect and for the driver org.apache.derby.jdbc.EmbeddedDriver.

Same result for other versions of the JDBC driver.

Presumably the workaround is to map the column to a single character containing "Y" and "N". But I'd rather do it properly.

Did anybody encountered this problem too ?

Jan Goyvaerts
  • 2,913
  • 4
  • 35
  • 48

2 Answers2

1

Pass true as query parameter

SELECT b.id FROM Bar b WHERE b.latest = :latest

will work for sure.

Igor Azarny
  • 124
  • 1
  • 3
0

Perhaps your Hibernate DerbyDialect doesn't precisely match your version of Derby. Derby's handling of BOOLEAN data types changed a few releases back, and I think that you have to make sure that the clients are using the correct JDBC APIs that match the BOOLEAN datatype. An older release of Derby supported only INTEGER, not BOOLEAN.

Providing more details in your question would be very valuable. Note the precise versions of all the software packages involved, include the complete stack trace of the error message that occurs, and post a snip of source code of the precise place in your program where the error arises.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • could be that this change is in [10.8.1.2](https://db.apache.org/derby/releases/release-10.8.1.2.html#Overview) which is the current version. – oers Apr 04 '12 at 14:32
  • I've tried the last three versions: 10.8.2.2, 10.8.1.2 and 10.7.1.1. All with the embedded database. – Jan Goyvaerts Apr 04 '12 at 17:39