I have 2 tables:
Table1
-a1 (PK)
-a2(PK)
-a3(PK)
-a4
-a5
......
Table2
-k1(PK)
-k2(PK)
-k3
.....
So there 2 tables (both with composite IDs, but I don't think makes too much of a difference in this case) that have no database driven association.
But I need to be able to do a query that joins these two:
ie
select * from Table1 t1, Table2 t2
where t1.a4 = t2.k3
and t1.k1= 'ABC'
So I think the DetachedCriteria would look something like:
Code:
DetachedCriteria crit = DetachedCriteria.forClass(Table1.class);
crit.createCriteria("table2", DetachedCriteria.LEFT_JOIN).add(Expression.eq("k1", "ABC"));
List<Table1> listOfTable1s = getHibernateTemplate().findByCriteria(crit);
Can someone help me out with the mapping? Or if there is alternative solution I can implement in the DetachedCriteria?
If its easier for you to provide insight to the xDoclet2 config for this item..... even better.
Thanks in advance.