Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differerence between hibernate types: boolean, yes_no, true_false

When to use each? To what do they map in the database?

like image 942
flybywire Avatar asked Jan 27 '10 06:01

flybywire


People also ask

What are hibernate types?

These types of mapping have data types defined as “integer”, “character”, “float”, “string”, “double”, “Boolean”, “short”, “long” etc. These are present in hibernate framework to map java data type to RDBMS data type.

Does hibernate support JSON data type?

Spring Data / Hibernate does not support JSON fields out-of-the-box, but there is a library that provides custom types for the most common database systems: hibernate-types.


2 Answers

Follow true_false, if you like T/F at database level. Otherwise, use yes_no, it will give you Y/N in the database.

By the way, got to know that there are some issues with these, which result in unexpected value. For example here and here, Few seems fixed already in successive updates, though.

like image 131
Adeel Ansari Avatar answered Oct 11 '22 13:10

Adeel Ansari


from Hibernate: http://docs.jboss.org/hibernate/stable/core.old/reference/en/html_single/#mapping-types-basictypes

boolean, yes_no and true_false are all alternative encodings for a Java boolean or java.lang.Boolean.

like image 35
mlathe Avatar answered Oct 11 '22 14:10

mlathe