Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Mapping boolean value
PostPosted: Fri Apr 13, 2007 11:07 am 
Beginner
Beginner

Joined: Fri Apr 13, 2007 9:27 am
Posts: 33
Hello:
I am using Hibernate tools 3.2 Eclipse plugin.

I have some data fields of type 'numeric' in a databse table. There is a rule states that the field value is either '1' or '0'.
Hibernate generation tool sets the type of those fields to boolean.

Can some explain to me why Hibernate using 'boolean' instead of 'numeric'?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 12:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8611
Location: Neuchatel, Switzerland (Danish)
there is no java nor hibernate type called 'numeric' and if your numeric is of length 1 then it maps perfect to a boolean, right?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 12:36 pm 
Beginner
Beginner

Joined: Fri Apr 13, 2007 9:27 am
Posts: 33
max wrote:
there is no java nor hibernate type called 'numeric' and if your numeric is of length 1 then it maps perfect to a boolean, right?


So, what you saying is that Hibernate will convert the boolean value to numeric when persisting an object?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 12:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8611
Location: Neuchatel, Switzerland (Danish)
did you try it before assuming it wont work ?

your jdbc driver should do the job for you in this case.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 1:40 pm 
Beginner
Beginner

Joined: Fri Apr 13, 2007 9:27 am
Posts: 33
max wrote:
did you try it before assuming it wont work ?

your jdbc driver should do the job for you in this case.


I did not assume it won't work. I would try it if I could. We are in the early stages of a new project. The database is being modoled, and I am learing Hibernate.
After I used Hibernate tools (defualt configurations) to generate the Beans and the mapping files, I noticed that the 'numeric' type was substitued by 'boolean'. I couldn't find any relevent information in the reference manual. So, I thought to join the forum and maybe I find someone who can explain what has happened behind the scene.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 3:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8611
Location: Neuchatel, Switzerland (Danish)
numeric with length 1 is a comon way of modelling boolean on dbs that does not have a boolean type

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 9:55 pm 
Beginner
Beginner

Joined: Fri Apr 13, 2007 9:27 am
Posts: 33
max wrote:
numeric with length 1 is a comon way of modelling boolean on dbs that does not have a boolean type


I think you need to read the question carefully..!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 14, 2007 2:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8611
Location: Neuchatel, Switzerland (Danish)
question: "I have some data fields of type 'numeric' in a databse table. There is a rule states that the field value is either '1' or '0'.
Hibernate generation tool sets the type of those fields to boolean."

answer(s):there is no java nor hibernate type called 'numeric' and if your numeric is of length 1 then it maps perfect to a boolean. numeric with length 1 is a comon way of modelling boolean on dbs that does not have a boolean type

What are am I missing ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

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.