The moose likes Object Relational Mapping and the fly likes help: Duplicate mapping exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "help: Duplicate mapping exception" Watch "help: Duplicate mapping exception" New topic

help: Duplicate mapping exception

Juzar Roopawalla
Ranch Hand

Joined: Oct 30, 2001
Posts: 37
I have all my hbm.xml files in a jar which is inside a war. I get the following on initialization:

Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping com.msdw.pbefficiency.servicestracker.hibernate.pojo.TimeEntry.timeEntryDetailsList at org.hibernate.cfg.Mappings.addCollection(
at org.hibernate.cfg.HbmBinder.createClassProperties(
at org.hibernate.cfg.HbmBinder.createClassProperties(
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder
at org.hibernate.cfg.HbmBinder.bindRootClass(
at org.hibernate.cfg.HbmBinder.bindRoot(
at org.hibernate.cfg.Configuration.add(
at org.hibernate.cfg.Configuration.addInputStream(
at org.hibernate.cfg.Configuration.addResource(
... 62 more
Initial SessionFactory creation failed.javax.naming.NamingException: Could not read
mappings from resource: com/msdw/pbefficiency/servicestracker/TimeEntry.hbm.xml

TimeEntry.hbm.xml is:

<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping (View Source for full doctype...)>
- <hibernate-mapping default-cascade="none" default-access="property" default-lazy="true" auto-import="true">
- <class name="com.msdw.pbefficiency.servicestracker.hibernate.pojo.TimeEntry" table="TimeEntry" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version">
- <id name="timeEntryId">
<generator class="native" />
- <!-- foreign key will be inserted by parent class - TimeSheet
<property name="timeSheetId" insert="false" update="false" unique="false" optimistic-lock="true" lazy="false" generated="never" />
<property name="userMins" column="userMinutes" unique="false" optimistic-lock="true" lazy="false" generated="never" />
<property name="clientId" unique="false" optimistic-lock="true" lazy="false" generated="never" />
<property name="comments" unique="false" optimistic-lock="true" lazy="false" generated="never" />
- <list name="timeEntryDetailsList" cascade="all" lazy="false" inverse="false" mutable="true" optimistic-lock="true" embed-xml="true">
<key column="timeEntryId" not-null="true" on-delete="noaction" />
<index column="idx" />
<one-to-many class="com.msdw.pbefficiency.servicestracker.hibernate.pojo.TimeEntryDetails" not-found="exception" embed-xml="true" />

Unfortunately there is no help on this anywhere on the internet. Could any one throw some light on this issue ASAP. Thanks a lot in advance!
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

From reading the exception message, I'm guessing you have mapped a collection more than once. Have you defined TimeEntry.hbm.xml more than once in your configuration file?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Juzar Roopawalla
Ranch Hand

Joined: Oct 30, 2001
Posts: 37
yes, thanks that was the problem. but due to the nature of the error i was concentrating more on the hbm.xml rather than looking into the cfg.xml.
thanks once again.
I agree. Here's the link:
subject: help: Duplicate mapping exception
It's not a secret anymore!