What does Hibernate map a boolean datatype to when using an Oracle database by default?

前端 未结 3 1676
南旧
南旧 2020-12-29 02:47

By default if I create a field in an entity like:

@NotNull
boolean myBoolean;

And I let Hibernate auto-create my tables. What Oracle data t

3条回答
  •  灰色年华
    2020-12-29 03:32

    As @Arthur said it maps to Number(1) which would be the standard sql bit where 0 == false and 1 == true. As an alternative you can map char(1) to 'T' or 'F' like this

    @org.hibernate.annotations.Type(type="true_false")
    @NotNull
    boolean myBoolean;
    

    or map it to 'Y' or 'N'

    @org.hibernate.annotations.Type(type="yes_no")
    @NotNull
    boolean myBoolean;
    

提交回复
热议问题