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
|