-->
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.  [ 6 posts ] 
Author Message
 Post subject: "could not execute query" Error
PostPosted: Tue May 29, 2007 11:42 am 
Newbie

Joined: Tue May 29, 2007 11:28 am
Posts: 3
Settings for hibernate:

<property name="PSavings" type="java.lang.Double" column="`PSAVINGS`" not-null="false"/>

The query looks something like:

"select * from X where PSavings = :parameter"

And this is the trouble part:

if i bind the "parameter" like:
"query.setDouble('parameter",Double.parseDouble(value));"
then it works fine. But if i do it like:
"query.setLong("parameter",Long.parseLong(value));"
then the hole application drops: "Server failed to resume the transaction, desc: 8800000008.".

What is the problem? Why it's not posible to convert from Long to Double? Can you give me a workarround? Because there are some cases when i really have to bind it like "Long" not "Double".


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 29, 2007 12:12 pm 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi nila_andrei,
if you have stored it as a double, why you wanna retrieve it as a Long? You can still retrieve the Double value and then if you like, transform it as Long in the Java code

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 2:48 am 
Newbie

Joined: Tue May 29, 2007 11:28 am
Posts: 3
chucky wrote:
Hi nila_andrei,
if you have stored it as a double, why you wanna retrieve it as a Long? You can still retrieve the Double value and then if you like, transform it as Long in the Java code


Well the is like this:
If i bind the "parameter" as "Double" for example "20.15" only the exact values are returned. If i bind it as "Long" for example "20" all the numbers between 19.5 -> 20.49 are returned, and in some cases i need the second bind type. This works just fine if a mapp the properties as "String" but not as "Double" why?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 4:28 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
In this case you can create (customize) your own type to reflect the behavior you want. You can extend org.hibernate.UserType or org.hibernate.CompositeUserType. For more details, please check the reference doc.

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 5:52 am 
Newbie

Joined: Tue May 29, 2007 11:28 am
Posts: 3
chucky wrote:
In this case you can create (customize) your own type to reflect the behavior you want. You can extend org.hibernate.UserType or org.hibernate.CompositeUserType. For more details, please check the reference doc.


This would be to complicated, my case is a particular one...in a big application, i cant modify that code. I'am just asking for a work arround ideea. Why does hibernate cant switch from Long to Double?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 30, 2007 6:15 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
This is a fact that is explain somewhere in the hibernate doc (I think about hibernate type system). If you want a different behavior, you have to do it yourself. But if you say that it works with strings, the easiest way should be to map as a string and to transform it in your java code.

_________________
chucky

Don't forget to rate if this helps
-----------------------------------


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