-->
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.  [ 1 post ] 
Author Message
 Post subject: BAD Native SQL in Hibernate - Inheritance scenario
PostPosted: Fri Jun 20, 2008 3:12 am 
Newbie

Joined: Fri Jun 20, 2008 2:52 am
Posts: 2
Hi,

We have a case where we have two tables Customer(parent) and CustomerExtension(child). The CustomerExtensionDBVO generated represents CustomerExtension table is created using joined-subclass tag.

Quote:
<joined-subclass name="com.xxx.persistence.user.CustomerExtensionDBVO"
extends="com.xxx.persistence.user.CustomerDBVO"
table="CUSTOMER_EXTENSION" lazy ="true">
<key column="CUSTOMER_GUID"/>

.......
.......
</joined-subclass>

CustomerDBVO as follows:

<class
name="com.xxx.persistence.user.CustomerDBVO"
table="CUSTOMER"
>
<property name="auditInfo"
type="com.xxx.persistence.AuditInfoType">
<column name="UPDATED_DATE"/>
<column name="CREATED_DATE"/>
</property>
............
............


We need to write a query which will fetch records based on updated_date. But we cannot use HQL, as it does not support multi-column queries. So we are using native sql. The hibernate documentation says that we need to give all the columns from both the tables. We tried following query but it does not work:

Quote:
getSession().createSQLQuery("SELECT {c.*}, {c1.*} FROM customer c, customer_extension c1 WHERE trunc(c.UPDATED_DATE,'DD') = trunc(:date,'DD')")
.addEntity("c1",CustomerExtensionDBVO.class)
.setTimestamp("date", updateDate)
.list();


It gives error saying UPDATED_DATE is invalid identifier. I think we do not understand how to write the query for this scenario correctly.
Can someone please paste an example for the same?

Thank you in advance.

Regards,
Brahma.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.