Joined: Mon Oct 24, 2005 6:44 am Posts: 11
|
Hi
I am using MYSQL Database with Eclipse helios. I am having problem adding object to POJO (Class created by Hibernate reverse engineering). I have two tables customer and stitle. I have created One-to-Many relationship in MYSQL between this two tables. titleId is foreign key in customer table. so one to many relation exist.
customer customerId as int(11) primary Key titleId as Int(11) foreignKey FK_CTitleId (which is match to titleId in stitle table) firstname as string(45)
stable
titleId as int(11) primary Key title as string(45)
When I run reverse engineering, I get two object STitle.java and Customer.java. Also get two Customer.hbm.xml and Stitle.hbm.xml. But I am getting titleId in Customer object as an Integer and not as STitle object.
Here is my hibernate-reverse-engineering file.
<code> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering> <table-filter match-catalog="PMS1" match-name="stitle"/> <table-filter match-catalog="PMS1" match-name="customer"/>
<!-- PMS1 schema --> <table schema="PMS1" name="customer"> <primary-key> <generator class="native" /> </primary-key> <foreign-key constraint-name="FK_CTitleId"> <many-to-one property="stitle"/> <set property="customer"/> </foreign-key> </table> <table schema="PMS1" name="stitle"> <primary-key> <generator class="native" /> </primary-key> </table> </hibernate-reverse-engineering>
</code>
JAVA object it created
<code> public class Customer implements java.io.Serializable {
private Integer customerId; private Integer titleId; private String firstName;
public Customer() { }
public Integer getCustomerId() { return this.customerId; } public void setCustomerId(Integer customerId) { this.landlordId = landlordId; }
public Integer getTitleId() { return this.titleId; } public void setTitleId(Integer titleId) { this.titleId = titleId; } public String getFirstname() { return this.firstname; } public void setFirstName(String firstname) { this.firstname = firstname; } } </code>
I don't understand why it is creating titleId as integer. It suppose to be object for table sTitle. Please can someone help me. Many thanks
|
|