Hibernate JPA, MySQL and TinyInt(1) for Boolean instead of bit or char

后端 未结 6 2130
感情败类
感情败类 2020-12-12 23:38

Here is my JPA2 / Hibernate definition:

Code:
@Column(nullable = false)
private boolean enabled;

In MySql this column is resolved to a bit(

6条回答
  •  星月不相逢
    2020-12-13 00:28

    I had this error:

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/context-config.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not determine type for: org.hibernate.type.NumericBooleanType, at table: bookingItem, for columns: [org.hibernate.mapping.Column(enabled)]

    And this worked for me:

    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean enabled;
    

提交回复
热议问题