-->
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.  [ 2 posts ] 
Author Message
 Post subject: Criteria: Access query results with joined tables
PostPosted: Sat Nov 07, 2009 10:21 am 
Newbie

Joined: Sat Nov 07, 2009 7:19 am
Posts: 1
Hi @ all!

I figured out how to use hibernate criteria queries but when joining tables, i got stuck. I've got two tables as described below and there is a relationship (one-to-many) --> table2.idOfTable1 = table1.id

[Table1]
id.....................int
label................varchar
anotherField......int

[Table2]
id....................int
idOfTable1........int
field4...............int

Code:
...
session.createCriteria(Table2.class);
criteria.createAlias("idOfTable1", "tab1");
List<Table1> critList = criteria.list();
for (int i = 0; i < critList.size(); i++ ){
  //Access the result objects/fields...
}


My problem is, that I don't know how to access the columns of Table1. The list includes objects of type "Table2" but I'd like to retrieve the whole result of the query. --> table2.id, table2.field4, table1.label, table1.anotherField.

I'm sure you know how this works... any help is very much appreciated!

Regards,
Martin


Top
 Profile  
 
 Post subject: Re: Criteria: Access query results with joined tables
PostPosted: Tue Nov 10, 2009 5:23 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
So you don't want to get Objects, but something like an object array with all columns your query should return?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.