aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to Parse Multitple Entities In Hibernate NativeSQL Returned List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to Parse Multitple Entities In Hibernate NativeSQL Returned List" Watch "How to Parse Multitple Entities In Hibernate NativeSQL Returned List" New topic
Author

How to Parse Multitple Entities In Hibernate NativeSQL Returned List

yekhon wong
Greenhorn

Joined: Jul 25, 2011
Posts: 1
Hi,

In some of the code of my application, the Native SQL is required somehow so that I could use the xpath syntax to search a XML column in our Ms SQL database. And in the Native SQL I need to return a list with multitple entities.
From the url http://docs.jboss.org/hibernate/core/3. ... l#d0e13763, I able to find a sample of adding multiple entities into a single native SQL with below code:

String sql = "SELECT ID as {c.id}, NAME as {c.name}, " +
"BIRTHDATE as {c.birthDate}, MOTHER_ID as {c.mother}, {mother.*} " +
"FROM CAT_LOG c, CAT_LOG m WHERE {c.mother} = c.ID";

List loggedCats = sess.createSQLQuery(sql)
.addEntity("cat", Cat.class)
.addEntity("mother", Cat.class).list()

However I am wondering after we get the returned list, how should we further parse the list element into entities "cat" and "mother" ?
Appreciate if somebody could gimme some guidance.
Thanks.
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 513

Wont the mother id of the cat object be null for mother cat?


If you are not laughing at yourself, then you just didn't get the joke.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Parse Multitple Entities In Hibernate NativeSQL Returned List