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 

Joined: Mon Oct 24, 2005 6:44 am
Posts: 11

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.


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)


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.

<?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" >

<table-filter match-catalog="PMS1" match-name="stitle"/>
<table-filter match-catalog="PMS1" match-name="customer"/>

<!-- PMS1 schema -->
<table schema="PMS1" name="customer">
<generator class="native" />
<foreign-key constraint-name="FK_CTitleId">
<many-to-one property="stitle"/>
<set property="customer"/>

<table schema="PMS1" name="stitle">
<generator class="native" />


JAVA object it created

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;


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

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 2015, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.