-->
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.  [ 3 posts ] 
Author Message
 Post subject: Custom SQL query and formula property.
PostPosted: Wed Mar 06, 2013 8:47 am 
Newbie

Joined: Wed Mar 06, 2013 8:29 am
Posts: 3
Hi, has anyone got any tips on using a custom sql query (can't use hql as need connect by prior) and i have added a property with a formula. I just keep getting NPE - like bug HHH-2536 (https://hibernate.onjira.com/browse/HHH-2536), but I'm using version 4.1.9.final which i think has been resolved. (dialect is Oracle).

Here's the relevant bit of my hbm.xml (obviously just using sysdate to test things out as gives same NPE):

<property name="test" formula="(select to_char(sysdate) from dual)" type="string"/>
...
<sql-query
name="mblTree"> SELECT m.*, (select to_char(sysdate) from dual) test
FROM mytable m
START WITH mbl_title = :startMblTitle
CONNECT BY PRIOR mbl_id = mbl_parent_id
<return alias="MyTable" class="com.processor.MyTable"/>
</sql-query>

Any help would be much appreciated.

Tim.


Top
 Profile  
 
 Post subject: Re: Custom SQL query and formula property.
PostPosted: Wed Mar 06, 2013 9:28 am 
Newbie

Joined: Sun Aug 23, 2009 7:53 am
Posts: 8
Location: India
You may use NamedQuery.

http://www.roseindia.net/hibernate/hibernate4/HibernateNamedNativeSQLXML.shtml

_________________
Niraj


Top
 Profile  
 
 Post subject: Re: Custom SQL query and formula property.
PostPosted: Wed Mar 06, 2013 9:54 am 
Newbie

Joined: Wed Mar 06, 2013 8:29 am
Posts: 3
Thanks for the reply, but might have misunderstood my issue. The problem is when I add another property to my hbm.xml file that is a formula (works fine if its just mapped to a column)...

<property name="test" formula="(select to_char(sysdate) from dual)" type="string"/>

The formula works by itself, and the query works by itself (with just m.*) but together they throw NPE which is exactly what was specified here: https://hibernate.onjira.com/browse/HHH-2536, but this has been fixed, but can't find any usage notes on it.

Cheers,

Tim.


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