-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problems mapping boolean/tinyint/bit type via annotations
PostPosted: Mon Nov 03, 2008 1:50 pm 
Beginner
Beginner

Joined: Thu Oct 04, 2007 12:22 pm
Posts: 48
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.