askullhead askullhead - 1 year ago 79
Java Question

Configure hibernate (using JPA) to store Y/N for type Boolean instead of 0/1

Can I setup JPA/hibernate to persist

types as
? In the database (the column is defined as
. It currently stores them as
. The database is Oracle.

Answer Source

The only way I've figured out how to do this is to have two properties for my class. One as the boolean for the programming API which is not included in the mapping. It's getter and setter reference a private char variable which is Y/N. I then have another protected property which is included in the hibernate mapping and it's getters and setters reference the private char variable directly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download