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.