-->
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.  [ 1 post ] 
Author Message
 Post subject: Join tables without keys
PostPosted: Tue Aug 11, 2009 1:14 am 
Newbie

Joined: Thu Apr 17, 2008 3:46 pm
Posts: 5
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.