• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Oracle CONNECT BY

 
Piyush Mattoo
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a native sql query using the Oracle CONNECT BY clause. However, upon execution I see a SQLException stating Unexpected token: START. I tried tweaking the named query syntax but in vain.
The mapping file containing the named query is like this:

<hibernate-mapping>
<class name="com.xyz.core.commons.rdm.hibernate.AccountNumberHistory"
table="ACCT_NUM_HSTRY">
<id name="id" type="long">
<column name="ACCT_NUM_HSTRY_ID"/>
<generator class="sequence">
<param name="sequence">ACCT_NUM_HSTRY_ID_SEQ</param> </generator>
</id>
<property name="oldAccountNumber" type="string" not-null="true">
<column name="OLD_ACCT_NUM"/>
</property>
<property name="newAccountNumber" type="string" not-null="true">
<column name="NEW_ACCT_NUM"/>
</property>
<property name="insertTimeStamp" type="calendar" not-null="true">
<column name="TIME_STMP_ADD" />
</property>
<property name="updateTimeStamp" type="calendar" not-null="true">
<column name="TIME_STMP_UPDATE" />
</property>
</class>

<sql-query name="AccountNumberHistory.findByAccountNumber">
<return alias="anh" class="com.xyz.core.commons.rdm.hibernate.AccountNumberHistory"/>
<![CDATA[SELECT
{anh.*}
FROM
ACCT_NUM_HSTRY anh
start with NEW_ACCT_NUM = :accountNumber
CONNECT BY PRIOR OLD_ACCT_NUM = NEW_ACCT_NUM
]]>
</sql-query>
</hibernate-mapping>

And I call it like this (using Spring):
List<AccountNumberHistory> accountHistories = this.getHibernateTemplate().findByNamedQueryAndNamedParam(
"AccountNumberHistory.findByAccountNumber", "accountNumber", accountNumber);
I am using Hibernate 3.2 version.

Any inputs will be highly appreciated!

TIA!
 
Piyush Mattoo
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind..it does work with no extra tweaking
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic