• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Joining two unrelated tables

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .
 
reply
    Bookmark Topic Watch Topic
  • New Topic