-->
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.  [ 5 posts ] 
Author Message
 Post subject: Custom representation of boolean type in DB
PostPosted: Mon Apr 10, 2006 6:05 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
Hibernate version: 3.1.3

Name and version of the database you are using: Oracle 10g

I need to represent a boolean value in the database as 'Y' or 'N'. I'd rather not, but I have no control over DB design.... here's an example column:

Code:
CREATE TABLE whatever (
  some_flg CHAR(1) DEFAULT 'N' NOT NULL CHECK ( some_flg IN ( 'Y', 'N' ) )
);


Does hibernate have [some] built-in support for this sort of thing, or do I need to write my own custom type?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 12:50 am 
Regular
Regular

Joined: Wed Mar 08, 2006 2:07 am
Posts: 50
Location: Bangalore
This should solve your problem :

create a property like this in your spring file :

<prop key="hibernate.query.substitutions">true 'T', false 'F'</prop>


If still not satisfied see this :
hibernate-3.1\doc\reference\en\html_single\index.html

(3.4.5) Query Language Substitution


------
Prashant.Jain

Dont forget to rate !


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 5:04 am 
Newbie

Joined: Thu Nov 17, 2005 12:59 pm
Posts: 18
silvaran, see the hibernate docs, 5.2.2. Basic value types.
I think that the "yes_no" and "true_false" types are your choice. Also you can create your oun custom type for this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 11, 2006 5:12 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
Someone implemented a UserType to do this here: http://www.hibernate.org/189.html


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 10, 2006 10:54 pm 
Regular
Regular

Joined: Wed Feb 15, 2006 9:09 pm
Posts: 76
Wow, credits all around, thanks folks! :)


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