-->
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.  [ 11 posts ] 
Author Message
 Post subject: reverse engineering and code generation
PostPosted: Thu Mar 09, 2006 9:43 am 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
I was doing reverse engineering in eclipse with hibernate tools, and I have followed steps stated in the

http://www.hibernate.org/hib_docs/tools ... e/en/html/

all was going alright, in the hibernate configuration window I can see my database , tables ,objects but when I click code generation the strange message appears :

org.hibernate.cfg.JDBCBinderException: Foreign key name ($1) mapped to different tables!

I use PostgreSQL 7.4.7 and jdbc driver pg74.216.jdbc3.jar
and here is the code of my database:

create table car_owner(id serial primary key,name varchar(20),
surname varchar(20),jmbg integer);
create table reg_plate(id serial primary key,plate_signature char(2),
plate_number integer unique,id_car_owner integer references car_owner);
create table address(id serial primary key,street varchar(20),
city varchar(20),country varchar(20),id_car_owner integer references car_owner);

I would be gratefull if some could help me.

_________________
nikola_croatia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 6:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use proper unique names for your foreign keys. (later postgress' does this automatically afaik, but until then you have to name them uniquely your self)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 7:02 am 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
What did You mean under the term unique proper names , give an example ?

Even if I change the names of my foreign keys that doesn't matter a great thing with respect to stated error.

_________________
nikola_croatia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 8:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh why don't you think

org.hibernate.cfg.JDBCBinderException: Foreign key name ($1) mapped to different tables!

will change if you change the automatically generated (by postgress) key name $1 to something unique ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: So, that is
PostPosted: Fri Mar 10, 2006 11:37 am 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
What you have said concerns postgres server, but all the time I was thinking that you are trying to say that my problem is connected with the DDL ,i.e. the tables which I have created.

_________________
nikola_croatia


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 5:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh yes and ?

It relates to both since you have not been naming your foreign keys uniquely which is needed on older postgress'

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: thanks
PostPosted: Sat Mar 11, 2006 8:31 am 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
I have successfully solved my problem. The solution has been in the few lines of code

ALTER TABLE address ADD CONSTRAINT first_foreign_key FOREIGN KEY(id_car_owner) REFERENCES car_owner

ALTER TABLE reg_plate ADD CONSTRAINT second_foreign_key FOREIGN KEY(id_car_owner) REFERENCES car_owner

but manually changing of foreign keys are big burden if I have many tables, so I decided
to migrate to higher version of Postgress

SO MAX WHAT WOULD I DO WITHOUT YOUR SUGGESTIONS.
Nothing, sit and cry.

_________________
nikola_croatia


Top
 Profile  
 
 Post subject: Re: thanks
PostPosted: Sat Mar 11, 2006 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nikola_croatia wrote:
SO MAX WHAT WOULD I DO WITHOUT YOUR SUGGESTIONS.
Nothing, sit and cry.


so now you don't need to sit and cry couldn't you use a minute or two to put some details about this via the wiki page described here http://forum.hibernate.org/viewtopic.php?t=956490 ?

Thanks!

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: hm few minutes
PostPosted: Sat Mar 11, 2006 3:48 pm 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
Come on max, to post a litteraly correct prose isn't so easy as it may seems.
and you have to take in consideration that English is not my mother language.
But business must not take a burden and we users have to use such a great thing as hibernate is, without any obstacles on ours way.So I decided to get a 15minutes and post my problem, an example of the problem, and the solution at the stated page

http://forum.hibernate.org/viewtopic.php?t=956490 ?

_________________
nikola_croatia


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 11, 2006 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I appreciate the description (and english is also not my mother language)

In any case, the *wiki* is still the correct place to put this - e.g. put it on the driver page in short form and link to the bigger description.

In any case, thanks for the description.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: ok
PostPosted: Sat Mar 11, 2006 4:32 pm 
Newbie

Joined: Thu Mar 09, 2006 8:16 am
Posts: 13
good idea, I will put it.

_________________
nikola_croatia


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