In JPA how can i bind Y N to Boolean type -


is possible bind boolean variable varchar(1) y/n in mysql using jpa annotations ?

i using below mapping@basic @column(name = "is_active", columndefinition = "varchar", length = 1) private boolean active;

which throwing exception

java.lang.illegalargumentexception: parameter value [a] did not match expected type [java.lang.boolean (n/a)] 

so figured out reason error, because passing 'y' parameter named query.

params.put("isactive", "y"); 

but when changed

params.put("isactive", boolean.true); 

the query not returning result seems it's passing 'true' parameter query.

can tell me how correctly map ?

<dependency>         <groupid>org.jboss.spec</groupid>         <artifactid>jboss-javaee-all-6.0</artifactid>         <version>3.0.0.final</version>         <scope>provided</scope>     </dependency> 

safest way define attributeconverter maps boolean string , maps "y" or "n". define boolean field use attributeconverter.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -