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.