-->
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.  [ 6 posts ] 
Author Message
 Post subject: Reverse Engineering Question
PostPosted: Wed Sep 14, 2005 9:36 am 
Newbie

Joined: Wed Sep 14, 2005 9:15 am
Posts: 12
Location: St. Louis
I'm currently tesing Hibernate Tools with MySQL 4.1. In order to test the reverse engineering functionality, I created the following tables (SQL code was taken directly from MySQL's website):

CREATE TABLE parent(id INT NOT NULL,
PRIMARY KEY (id)
) TYPE=INNODB;

CREATE TABLE child(id INT, parent_id INT,
INDEX par_ind (parent_id),
FOREIGN KEY (parent_id) REFERENCES parent(id)
ON DELETE CASCADE
) TYPE=INNODB;

I then ran reverse engineering via Hibernate Tools. The reverse engineering worked perfectly (POJO's and .hbm's we created successfully), however upon inspecting the .hbm files further, I noticed the reverse engineering did not transform the foreign key constraints into <many-to-one> with a corresponding <set> with <one-to-many>. Basically, no relational mappings were created in the .hbm files.

I also tried reverse engineering the following tables (again, code taken from MySQL's website), however, no relational mappings were created:

CREATE TABLE product (category INT NOT NULL, id INT NOT NULL,
price DECIMAL,
PRIMARY KEY(category, id)) TYPE=INNODB;

CREATE TABLE customer (id INT NOT NULL,
PRIMARY KEY (id)) TYPE=INNODB;

CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,
product_category INT NOT NULL,
product_id INT NOT NULL,
customer_id INT NOT NULL,
PRIMARY KEY(no),
INDEX (product_category, product_id),
FOREIGN KEY (product_category, product_id)
REFERENCES product(category, id)
ON UPDATE CASCADE ON DELETE RESTRICT,
INDEX (customer_id),
FOREIGN KEY (customer_id)
REFERENCES customer(id)) TYPE=INNODB;

Any ideas why I'm not seeing the proper relational mappings show up in my .hbm files?

Thanks,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 11:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
only never versions of mysql have proper support for reporting foreign keys via metadata....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Reverse Engineering Question
PostPosted: Wed Sep 14, 2005 12:28 pm 
Newbie

Joined: Wed Sep 14, 2005 9:15 am
Posts: 12
Location: St. Louis
Max,

Thank you very much for your reply, I more than appreciate it!

As far as I can tell, MySQL 4.1 is the latest production-ready version of MySQL. Version 5.0 is out there, however, it's only in beta.

Will I have to run 5.0 in order to take advantage of reporting foreign keys via metadata, or is there another JDBC driver that will support this?

Again, thanks for your time, I more than appreciate it.

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 2:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i dont have a mysql install here i can test with, but know that people have done so successfully.....maybe enable logging and see if it reports anything interesting..

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Reverse Engineering Question
PostPosted: Wed Sep 14, 2005 7:19 pm 
Newbie

Joined: Wed Sep 14, 2005 9:15 am
Posts: 12
Location: St. Louis
Max,

I figured out the problem... I switched from the 3.1.7 driver version to the 3.1.10 version. That seemed to do the trick. Works perfectly now.

Just wanted to let you know.

Thanks,

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 1:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
thanks

_________________
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.  [ 6 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.