-->
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.  [ 2 posts ] 
Author Message
 Post subject: Does Reverse Engin.NEVER generate @OneToMany + @ManyToOne ?
PostPosted: Thu Feb 17, 2011 6:09 am 
Beginner
Beginner

Joined: Wed Oct 08, 2008 10:59 am
Posts: 37
I tried now a couple of different scenarios where I defined two tables (with a 1:n) relationship) in a MySQL database and used Hibernate Tools to generate corresponding, annotated java classes from them.

I found NO way to let Hibernate Tools generate the desired

@OneToMany(....)

or

@ManyToOne(....)

annotations. Assume for example the simplified table DDL below.
Why is there no @OneToMany generated in class for TAB1?
In other words: What do I have to change in the DDL to have Hibernate Tools
generate such a @OneToMany (and @ManyToOne) ?

CREATE TABLE TAB1 (
ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
OTHERFIELD VARCHAR(20) NULL;
PRIMARY KEY(ID),
INDEX TAB1_FKIndex1(ID)
);

CREATE TABLE TAB2 (
ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
DUMMYFIELD DATE NULL,
REFTOTAB1 INTEGER UNSIGNED NULL,
PRIMARY KEY(ID),
INDEX TAB2_FKIndex1(ID),
INDEX TAB2_FKIndex2(REFTOTAB1)
);


Top
 Profile  
 
 Post subject: Re: Does Reverse Engin.NEVER generate @OneToMany + @ManyToOne ?
PostPosted: Thu Feb 17, 2011 10:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there are no defined connections between the two tables you list.

define a foreign key.

_________________
Max
Don't forget to rate


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