Hi,
I'm wondering if I have wrong table setup, and I wanted to understand if what I'm generating is correct.
I'm using MySQL and I have two tables for example:
Code:
create table t1 (
t1id integer not null auto_increment primary key,
first varchar(20) not null,
last varchar(20) not null,
age integer null
) type=innodb;
create table t2 (
t1id integer not null,
index ( t1id ),
phone_number varchar(20) null,
phone_type varchar(20) null,
CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1id`) REFERENCES `t1` (`t1id`)
ON DELETE NO ACTION ON UPDATE NO ACTION
) type=innodb;
Basically the relationship between the two one to many. you can have multiple t2 records to a single t1 record. When I generate the entities, hbm2java is creating three files:
Code:
t1.java
t2.java
t2Id.java
In generating the entities I see the following:
Code:
[hibernate] Sep 28, 2009 3:05:37 AM org.hibernate.cfg.reveng.JDBCReader processPrimaryKey
[hibernate] WARNING: The JDBC driver didn't report any primary key columns in t2. Asking rev.eng. strategy
[hibernate] Sep 28, 2009 3:05:37 AM org.hibernate.cfg.reveng.JDBCReader processPrimaryKey
[hibernate] WARNING: Rev.eng. strategy did not report any primary key columns for t2
The t2Id.java file is throwing me off. Does this mean I have a created my tables in the wrong way? It seems like the table relationship is ok, where I have defined the key in the second table to be a foreign key which is the primary key in the first.
Is there away I can eliminate the Id file?
Thank you,
Christopher