hibernate类型之间的差异:boolean、yes_no、true_false

时间:2021-06-04 10:00:34

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

何时使用?它们在数据库中映射到什么?

2 个解决方案

#1


8  

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

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.

boolean、yes_no和true_false都是用于Java布尔或Java .lang. boolean的可选编码。

#2


5  

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

如果您喜欢在数据库级别上使用T/F,请遵循true_false。否则,使用yes_no,它将在数据库中提供Y/N。

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.

顺便说一下,我知道这些有一些问题,会产生意想不到的价值。例如,这里和这里,似乎没有几个已经在连续的更新中得到修复。

#1


8  

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

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.

boolean、yes_no和true_false都是用于Java布尔或Java .lang. boolean的可选编码。

#2


5  

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

如果您喜欢在数据库级别上使用T/F,请遵循true_false。否则,使用yes_no,它将在数据库中提供Y/N。

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.

顺便说一下,我知道这些有一些问题,会产生意想不到的价值。例如,这里和这里,似乎没有几个已经在连续的更新中得到修复。