Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Need help with reverse engineering to create java object
PostPosted: Thu Aug 11, 2011 6:21 am 
Newbie

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.