I am looking for something like this: (Please see that it uses all elements of composite key)
Code:
TableADAO dao = new TableADAO();
// Finding by all the values in primary key
TableAId id = new TableAId("1","1","1");
TableA tabA = dao.findById(id);
Set tabBs = tabA.getTableBs();
for (Iterator iter=tabBs.iterator(); iter.hasNext();){
TableB tabB = (TableB)iter.next();
System.out.println(tabB.getData());
}
Now I want to do the same with just two columns of the 3 column composite key.
All I can comeup with is
Code:
List bList = session.createCriteria("com.ccmc.beans.TableB")
.add( Restrictions.eq("id.colX", "1") )
.add( Restrictions.eq("id.colY", "1") )
.list();
for (Iterator iter=bList.iterator(); iter.hasNext();){
TableB tabB = (TableB)iter.next();
System.out.println(tabB.getData());
}
But I think this is as good as working on just tableB.
......