-->
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.  [ 4 posts ] 
Author Message
 Post subject: Boolean mapping
PostPosted: Thu Aug 25, 2005 8:21 am 
Newbie

Joined: Thu Aug 25, 2005 8:04 am
Posts: 3
Hibernate version: 3.05

Name and version of the database you are using: SQL-Server but should run anywhere

Hi all,

I am new to hibernate.
Have a table with a column 'is_user' of type SMALLINT, is there any way to map this to a java boolean/Boolean?

Thanks for answer or link (didn't find one so far)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 8:44 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Try this:

Code:
<property name="isUser" type="boolean">
    <column name="is_user" sql-type="smallint"/>
</property>


See the documentation for more information about sql-type.
http://www.hibernate.org/hib_docs/v3/re ... guide-s1-2

Best regards
Sven

_________________
Please don't forget to give credit, if this posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 8:58 am 
Beginner
Beginner

Joined: Tue Jun 28, 2005 4:33 pm
Posts: 21
I had a similar situation where our objects had Booleans, but the database was expecting a single character. We wrote a custom UserType and it solved the problem.

Sorry I don't have the exact link right now, but if you search the forum you should find some good examples on writing one.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 25, 2005 9:04 am 
Regular
Regular

Joined: Tue Nov 23, 2004 7:42 am
Posts: 82
Location: London, England
Depending on your DBMS you want something like this in your Hibernate config file (MySQL example):

Code:
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>



Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.