-->
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: createSQLQuery
PostPosted: Thu Feb 15, 2007 6:46 pm 
Newbie

Joined: Thu Aug 03, 2006 6:54 pm
Posts: 16
Hi there,

Im trying to execute an SQL query via Hibernate with the following piece of code:

Code:
List list = session.createSQLQuery("SELECT * from (SELECT {c.*} FROM customers c) AS customers, (SELECT {a.*} FROM account a) AS account")
           .addEntity("c", Customer.class)
           .addEntity("a", Account.class)
           .list();


This code runs without throwing any errors, however I am having difficulty accessing the results within the list.

i.e. when I only had simpler query such as:

Code:
List list = session.createSQLQuery("SELECT * from (SELECT {c.*} FROM customers c) AS customers")
           .addEntity("c", Customer.class)
           .addEntity("a", Account.class)
           .list();


I could extract the contents in the following way:
Code:
System.out.println(((Customer)result.get(0)).getfirstName());


However, this does not work with my more complex query.

Any help in this matter would be much appreciated.


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.