-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate mapping
PostPosted: Fri May 17, 2013 10:59 am 
Newbie

Joined: Fri May 17, 2013 10:18 am
Posts: 2
I am new to Hibernate, Trying to join 2 tables one-to-many

BusUnit.java:

public class BusUnit implements Serializable{

private static final long serialVersionUID = 1L;

private String busUnit;
private String psBusUnit;
private String legalEnt;
private Date startDate;
private Date endDate;
private String lastUpdtUsr;
private Date lastUpdtDt;
private BusUnitDesc busUnitDesc;

.......


BusUnitDesc.java

public class BusUnitDesc implements Serializable{

private static final long serialVersionUID = 1L;

private String busUnit;
private String busUnitDesc;
private Set<BusUnit> busUnits = new HashSet<BusUnit>(0);

BusUnit.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.common.db.busunit.BusUnit" table="TRSRV_PS_BUS_UNIT">
<composite-id>
<key-property name="legalEnt" column="LEGAL_ENTITY"></key-property>
<key-property name="busUnit" column="BUS_UNIT"></key-property>
<key-property name="startDate" column="START_DT"></key-property>
</composite-id>
<property name="endDate">
<column name="END_DT" />
</property>
<property name="psBusUnit">
<column name="PS_BUS_UNIT"/>
</property>
<property name="lastUpdtUsr">
<column name="LAST_UPDATE_USR_ID"/>
</property>
<property name="lastUpdtDt">
<column name="LAST_UPDATE_TS"/>
</property>
<many-to-one name="busUnitDesc" class="BusUnitDesc">
<column name="PS_BUS_UNIT" not-null="true" />
</many-to-one>


</class>
</hibernate-mapping>

BusUnitDesc.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.common.db.busunit.BusUnitDesc" table="TRSRV_PS_BU_DESC">
<id name="busUnit" type="string">
<column name="PS_BUS_UNIT" />
<generator class="assigned" />
</id>
<property name="busUnitDesc">
<column name="PS_BUS_UNIT_DESC" />
</property>
<set name="busUnits" table="TRSRV_PS_BUS_UNIT"
inverse="true" lazy="true">
<key>
<column name="PS_BUS_UNIT"/>
</key>
<one-to-many class="com.common.db.busunit.BusUnit" />
</set>
</class>
</hibernate-mapping>

hibernate.cfg.xml:
....
<mapping resource="resources/com/common/busunit/BusUnit.hbm.xml"/>
<mapping resource="resources/com/common/busunit/BusUnitDesc.hbm.xml"/>

Getting exception while running the following code: sessionFactory = config.buildSessionFactory();

org.hibernate.MappingException: An association from the table TRSRV_PS_BUS_UNIT refers to an unmapped class: BusUnitDesc
Any idea why I am getting it?
Thank you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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.