-->
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: hibernate.query.substitutions
PostPosted: Wed Apr 07, 2004 11:19 am 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
Hibernate 2.1.2. We have our booleans mapped as CHAR(1) in our Oracle9i database. (we have lookup data pointing to a DB2 db also) We would like to map/treat them as Booleans/booleans in our Hibernate POJO's. I added this mapping to the hibernate.cfg.xml:

Code:
<property name="hibernate.query.substitutions">true "Y", false "N"</property>


...and the property is mapped like so:

Code:
<property column="HAS_NOTES_FLAG" length="1" name="hasNotesFlag" type="java.lang.Boolean"/>


...but no I continue to get this error:
Code:
java.lang.NumberFormatException: Y
   at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1176)
   at java.lang.Double.valueOf(Double.java:168)
   at oracle.jdbc.driver.OracleStatement.getBooleanValue(OracleStatement.java:4393)
   at oracle.jdbc.driver.OracleResultSetImpl.getBoolean(OracleResultSetImpl.java:479)
   at oracle.jdbc.driver.OracleResultSet.getBoolean(OracleResultSet.java:1494)
   at net.sf.hibernate.type.BooleanType.get(BooleanType.java:19)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
   at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
   at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
   at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
   at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)


Any ideas? This seems like it should be easy, but I have never gotten it working. I tried a few months back and gave up. I have tried every possible combination in the substitution mapping, single quotes, reversing the order, etc... Any help would be appreciated. Thanks.

Matt Dowell


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 11:54 am 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
It looks like the query substitutions only help with HQL. I tried setting the property type to yes_no and Hibernate still expects some kind of boolean from the database.

Is there no way to map java type boolean to Oracle type char(1)?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 3:19 pm 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
I fixed it by creating my own custom persister. Easier than I thought. I added it to the wiki since I did not see an example there to convert CHAR to Boolean,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 1:24 am 
Newbie

Joined: Wed Apr 21, 2004 1:02 pm
Posts: 2
Matt,

Did you add your sollution to the wiki ? Can yoy point it to the page, I was not able to find it ?
I need to be able to customize the boolean values on the database.


Danilo.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 29, 2004 2:28 am 
Regular
Regular

Joined: Sat Oct 18, 2003 11:53 am
Posts: 55
I did, here is the link: http://www.hibernate.org/189.html



danilo_lr wrote:
Matt,

Did you add your sollution to the wiki ? Can yoy point it to the page, I was not able to find it ?
I need to be able to customize the boolean values on the database.


Danilo.


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.