Click here to Skip to main content
15,887,349 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a variable of type Boolean in my entity class by name "isActive". It to mapped to a column by name "is_active" with data type as bit.

@Column(name = "is_active")
private boolean isActive;

But when ever I try to save isActive attribute of the object, I get an error:
Java
column "is_active" is of type bit but expression is of type character 
varying Hint: You will need to rewrite or cast the expression.

How do I store the values the values of isActive? I want to store "1" in the database when value of "isActive" is true and "0" when "isActive" is false.

Thank you!

What I have tried:

Tried many online solutions like annotating with @Type annotations and adding various properties to the @Column annotation like
@Column(name = "is_active" nullable=false, columnDefinition="TINYINT", length=1)
etc...
Posted
Updated 27-Jul-17 8:39am

1 solution

I think in NHibernate the column type is TrueFalse, which expects 'T' or 'F'.
You would need to change the column type to Boolean.
See: Chapter 5. Basic O/R Mapping[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900