-->
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: Native SQL Query Problem
PostPosted: Mon Jul 18, 2005 8:20 am 
Newbie

Joined: Mon Jul 18, 2005 6:57 am
Posts: 12
I'm trying to use a native SQL query using session.createSQLQuery.

It works fine for me when I try and return a list of objects using

String sql = "SELECT {org.*} FROM organisational_unit org START WITH organisational_unit_id="+orgUnitId+" CONNECT BY PRIOR organisational_unit_id=orgunit_parent_id";

but if I try and return a column I get an SQLException: Invalid column name. I know that the query works as it runs directly against the database. The SQL string I'm using is:

String sql = "SELECT org.WORKFLOW_QUEUE_NAME as {org.queueName} FROM organisational_unit org START WITH organisational_unit_id="+orgUnitId+" CONNECT BY PRIOR organisational_unit_id=orgunit_parent_id";

List queues = getSession().createSQLQuery(sql, "org", OrgUnit.class).list();

Can anyone let me know if I'm doing something wrong here or if I'm missing something out.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 18, 2005 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
http://www.hibernate.org/hib_docs/v3/re ... l-creating


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 18, 2005 2:02 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
Had the same problem. If any of the columns that was mapped to the class was missing in the query, got the Invalid Column name exception.

Not sure if this is a feature or bug.


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.