Hi All ,
I have got the error
Code:
org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
but i dont see any duplicate
here is my related files
full error :
Code:
2010-08-04 18:45:57,599 INFO [org.hibernate.cfg.Configuration] configuring from resource: /hibernate.cfg.xml
2010-08-04 18:45:57,599 INFO [org.hibernate.cfg.Configuration] Configuration resource: /hibernate.cfg.xml
2010-08-04 18:45:57,601 INFO [org.hibernate.cfg.Configuration] Reading mappings from resource : com/db/hibernate/ActionHistory.hbm.xml
2010-08-04 18:45:57,604 INFO [org.hibernate.cfg.Mappings] duplicate import: com.db.ActionHistory->com.db.ActionHistory
2010-08-04 18:45:57,604 INFO [org.hibernate.cfg.Mappings] duplicate import: com.db.ActionHistory->ActionHistory
2010-08-04 18:45:57,604 INFO [org.hibernate.cfg.HbmBinder] Mapping class: com.db.ActionHistory -> action_history
2010-08-04 18:45:57,605 ERROR [STDERR] %%%% Error Creating SessionFactory %%%%
2010-08-04 18:45:57,605 ERROR [STDERR] org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/db/hibernate/ActionHistory.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at com.msgprocessor.hibernate.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:48)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.db.ActionHistory
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
at org.hibernate.cfg.Configuration.add(Configuration.java:669)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
... 13 more
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<!-- properties -->
<property name="connection.datasource">java:test/testBO</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Use the C3P0 connection pool. -->
<property name="c3p0.acquire_increment">3</property>
<property name="c3p0.idle_test_period">100</property>
<property name="c3p0.timeout">180</property>
<property name="c3p0.max_size">1000</property>
<property name="c3p0.max_statements">0</property>
<property name="c3p0.min_size">5</property>
<!-- Print SQL to stdout. -->
<property name="show_sql">false</property>
<property name="format_sql">false</property>
<!-- Hibernate XML mapping files -->
<mapping resource="com/db/hibernate/ActionHistory.hbm.xml" />
<mapping resource="com/db/hibernate/ActionInfo.hbm.xml" />
<mapping resource="com/db/hibernate/UserInfo.hbm.xml" />
</session-factory>
</hibernate-configuration>
ActionHistory.java
Code:
package com.db;
// default package
// Generated Aug 4, 2010 3:45:43 PM by Hibernate Tools 3.2.2.GA
import java.util.Date;
/**
* ActionHistory generated by hbm2java
*/
public class ActionHistory implements java.io.Serializable {
private Long actionHistoryId;
private ActionInfo actionInfo;
private UserInfo userInfo;
private Date time;
private String description;
public ActionHistory() {
}
public ActionHistory(ActionInfo actionInfo) {
this.actionInfo = actionInfo;
}
public ActionHistory(ActionInfo actionInfo, UserInfo userInfo, Date time,
String description) {
this.actionInfo = actionInfo;
this.userInfo = userInfo;
this.time = time;
this.description = description;
}
public Long getActionHistoryId() {
return this.actionHistoryId;
}
public void setActionHistoryId(Long actionHistoryId) {
this.actionHistoryId = actionHistoryId;
}
public ActionInfo getActionInfo() {
return this.actionInfo;
}
public void setActionInfo(ActionInfo actionInfo) {
this.actionInfo = actionInfo;
}
public UserInfo getUserInfo() {
return this.userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public Date getTime() {
return this.time;
}
public void setTime(Date time) {
this.time = time;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
}
ActionHistory.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Aug 4, 2010 3:45:44 PM by Hibernate Tools 3.2.2.GA -->
<hibernate-mapping>
<class name="com.db.ActionHistory" table="action_history" catalog="litrack">
<id name="actionHistoryId" type="java.lang.Long">
<column name="action_history_id" />
<generator class="identity" />
</id>
<many-to-one name="actionInfo" class="com.db.ActionInfo" fetch="select">
<column name="action_id" not-null="true" />
</many-to-one>
<many-to-one name="userInfo" class="com.db.UserInfo" fetch="select">
<column name="user_id" />
</many-to-one>
<property name="time" type="timestamp">
<column name="time" length="0" />
</property>
<property name="description" type="string">
<column name="description" />
</property>
</class>
</hibernate-mapping>
by the way i have added the lines
Code:
<property name="hibernate.archive.autodetection"></property>
<property name="hibernate.ejb.autodetection">hbm</property>
to hibernate.cfg.xml file but getting the same error .