Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I need to map a Java boolean to MySql via annotations. Therefore I defined in the bean class:
Code:
@Column(nullable = false)
private boolean allowed;
In MySql this column is resolved to a bit(1) datatype - which does not function, as intended. The problems are:
1. For legacy issues I need to map the boolean to a tinyint not to a bit. But I do not see a possibility to change the default datatype. Is there any?
2. The bean carrying the boolean value is very straigthforward: Default constructor doing nothing, values to default. But nonetheless, the boolean value (default to false) is
always mapped as MySql-Bit(1) = b'1'. If I try something like this:
Code:
MyBean bean = new MyBean();
bean.setAllowed(false);
session.save(bean);
The data is saved for all attributes correctly except the attribute allowed is always b'1' (true). Can anyone explain this phenomenon?
Hibernate version:
3.3
Name and version of the database you are using:
MySql 5.1