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, table
1.label, table
1.anotherField.
I'm sure you know how this works... any help is very much appreciated!
Regards,
Martin