-->
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.  [ 3 posts ] 
Author Message
 Post subject: Database without Foreign Keys
PostPosted: Fri Jun 20, 2008 9:06 am 
Newbie

Joined: Fri Jun 20, 2008 8:56 am
Posts: 15
Hello.

I´m new to Hibernate and I want to know if working with a database wich doesn´t use Foreign Keys between tables, I can define these relations in an hibernate-mapping file.
For example I have 2 tables, Departements and Users and Users has a field called Dept but no FK references Departments table.
In Hibernate what would happen if I create Departments hibernate-mapping file and Users hibernate-mapping file with one to many relationship???

Thanks!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 11:21 am 
Beginner
Beginner

Joined: Tue Dec 12, 2006 6:43 am
Posts: 32
Location: London
Hi,
Hibernate needs to map the object relation into a database relation. Which means if User has many Dept. so in the Dept. table there would be an FK (UserId) to represent this multiplicity. Please read a book called Hibernate In Action first to understand the ORM

Regards,

_________________
Alan Mehio
London
UK


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 21, 2008 7:25 am 
Newbie

Joined: Fri Jun 20, 2008 8:56 am
Posts: 15
Thank´s for the link to Hibernate In Action, it´s been very usefull.
If I´ve understood ok, relations between tables must been defined using Foreign Keys so Hibernate can do mapping all right.

Then although I have a column called Dept in User table, if this column isn´t defined as a FK to Department PK table, Hibernate won´t do the mapping ok. Is that?

Thank´s.


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

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.