• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Joining two unrelated tables

 
mysha ahamed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need help...I have a problem like I have 2 unrelated tables...
I associated them using <one -to many>..The main issue is I need to join them on Keys which r not primary or foreign keys...
The tables r not related and there r no common keys..

I specified in hbm file:
<many-to-one property-ref="mykey"/>

Though I specified the key on which to do join using
" property-ref", Hibernate is joining on primary keys of the associated class..How to tell hibernate to do join on my specific keys..
There r no fields commonn to both tables...
Any idea how to do this wuld be grt help..
Thnx,.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The main issue is I need to join them on Keys which r not primary or foreign keys...

If you really want to do this, do it in HQL, not in your mapping. You can't describe a relationship in an RDBMS without adding a foreign key constraint, so you shouldn't be trying to do it in the ORM layer.

(Could you also refrain from using abbreviated versions of English words in your posts ("grt", "r" etc.)? It makes post harder to understand (especially for non-English speakers) and people tend not to answer posts written that way.)
[ January 31, 2006: Message edited by: Paul Sturrock ]
 
riaz rahman
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you solved this problem?. i am also facing the same problem.
please let me know if you have solved .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic