-->
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.  [ 5 posts ] 
Author Message
 Post subject: Reverse Engineering Foreign Key relationships
PostPosted: Tue Jan 06, 2009 1:37 am 
Beginner
Beginner

Joined: Wed May 10, 2006 9:43 pm
Posts: 30
Location: Australia
Dear Hibernate users,

I'm using Hibernate Tools 3.0.0 in Eclipse 3.4.1.

I've been using the reverse engineering functionality. I would like to know if it is possible to reverse engineer a relationship where the parent table has a primary key and the child tables have foreign keys (which is the primary key of the parent table). I would like to link the data within the database using one id.

I received the following error:

org.hibernate.cfg.reveng.JDBCReader - The JDBC driver didn't report any primary key columns in tb_products. Asking rev.eng. strategy

Are there any examples to implement this (i.e. changes to the hibernate.reveng.xml file)? or ideas how to implement this.

Thanks Alyssa


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2009 10:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not sure what your first question is about - that is just normal many-to-one associations, right ?

But about the warning in the logs it indicates there is no primary keys defined for the table ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2009 8:00 pm 
Beginner
Beginner

Joined: Wed May 10, 2006 9:43 pm
Posts: 30
Location: Australia
Yes thats right, do i need to have a primary key in every table? I thought it would be okay to have a foreign key ? Which is actually a reference to the primary key in the parent table.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 5:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
The table should still have a primary-key if you want to have an association.

Otherwise you are looking at it being a join-table which is not something the reverse engineering supports - you can map that with hbm.xml or annotations though.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 11, 2009 4:06 am 
Beginner
Beginner

Joined: Wed May 10, 2006 9:43 pm
Posts: 30
Location: Australia
Thanks for your advice.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.