1
votes

I have a property created like this in my model:

 public class Client {
    private Boolean supervisor;
 }

When doing a query using Criteria, for example: p4 = cb.isTrue (root.get ("supervisor")), JPA returns an error client0_.supervisor = 1 - ERROR: conversion error of string "1" [SQLState: 22018, ISC error code: 335544334]. How can I solve this?

My RDBMS is Firebird and the supervisor column is of type BOOLEAN.

2
What is the type of the column in the database? If its a varchar, you will need a converter to turn it into a boolean. (Or change the type of the column) - Carl Shiles
My RDBMS is Firebird and the supervisor column is of type BOOLEAN. - Rodrigo
jpa reads and writes correctly in the database field, the problem is only in the where of the Criteria - Rodrigo

2 Answers

1
votes

It is kind of hard to tell with the information given, but what is probably happening is that your implementation of JPA is hibernate, and hibernate probably has no dialect for Firebase, so you are using some other dialect instead, (like H2 dialect,) and this dialect probably does not handle the boolean data type correctly.

You need to first verify that this is indeed the case, and if so, you will need to either find, or implement, a Hibernate dialect for Firebase that fixes this. It is certainly more work than just tweaking a setting, but it does not require a herculean effort, look here for an example:

HSQL + Hibernate Exception: Wrong column type: Found: double, expected: float

0
votes

I have managed to solve the problem, not with Criteria, but with JPQL, as follows:

select     new Extensionista(e.id, e.name) 
from       Extensionista e 
join       e.localControle lc 
where      lc.id =: id 
and        e.cpf is not null 
and        e.status = 'T' 
and        e.supervisor = 'true'
order by   e.name