Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Problem with Oracle CONNECT BY

 
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
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic