-->
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.  [ 2 posts ] 
Author Message
 Post subject: MappingException - solution
PostPosted: Wed Feb 15, 2006 6:36 pm 
Beginner
Beginner

Joined: Thu Jun 23, 2005 10:23 pm
Posts: 22
I've run into a MappingException during a session.save(object) after migrating from hibernate 2.0 to 3.1.2. Please note that there is no class name associated with the error "Unknown entity: " - Anyone have any ideas on why this would be?

Thanks in advance for your help.

Hibernate version:
Version 3.1.2

Mapping documents:
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="com.kohls.pm.pp.common.entity.PermPriceChangeEvent"
table="PET_PERM_EVNT"
select-before-update="true"
>

<id
name="id"
type="java.lang.Long"
column="PERM_EVNT_ID"
unsaved-value="-1"
>
<generator class="sequence">
<param name="sequence">PES_PRCHG_SEQ</param>
</generator>
</id>

<property
name="effectiveDate"
type="java.util.Calendar"
column="EFF_DTE"
not-null="true"
length="7"
/>
<property
name="inProcessDate"
type="java.util.Calendar"
column="INPROC_TMST"
length="7"
/>
<property
name="lockoutDate"
type="java.util.Calendar"
column="LCK_OUT_TMST"
not-null="true"
length="7"
/>
<property
name="permEvntNm"
type="java.lang.String"
column="PERM_EVNT_NM"
length="30"
/>
<property
name="ohAutoCountIndicator"
type="java.lang.String"
column="OH_AUTO_CNT_IND"
length="1"
/>
<property
name="statusCode"
type="java.lang.String"
column="STAT_CDE"
not-null="true"
length="1"
/>
<property
name="createDate"
type="java.util.Calendar"
column="CRE_TMST"
not-null="true"
length="7"
/>
<property
name="creator"
type="java.lang.String"
column="CRE_BY_USR_ID"
not-null="true"
length="8"
/>
<property
name="lastUpdateDate"
type="java.util.Calendar"
column="LAST_UPD_TMST"
not-null="true"
length="7"
/>
<property
name="lastUpdater"
type="java.lang.String"
column="LAST_UPD_BY_USR_ID"
not-null="true"
length="8"
/>

<!-- associations -->
<!-- bi-directional one-to-many association to PetPermEvntDeptOvrrid -->
<bag
name="departmentOverrides"
lazy="true"
inverse="true"
cascade="save-update"
>
<key>
<column name="PERM_EVNT_ID" />
</key>
<one-to-many
class="com.kohls.pm.pp.common.entity.PermEventDepartmentOverride"
/>
</bag>
<!-- bi-directional one-to-many association to PetStrGpPrchgAssn -->
<bag
name="strGpPrchgAssns"
lazy="true"
inverse="true"
>
<key>
<column name="PERM_EVNT_ID" />
</key>
<one-to-many
class="com.kohls.pm.pp.common.entity.hibernate.PetStrGpPrchgAssn"
/>
</bag>
<!-- bi-directional one-to-many association to PetPermEvntMdseSeln -->
<bag
name="merchandiseSelections"
lazy="true"
inverse="true"
cascade="save-update"
>
<key>
<column name="PERM_EVNT_ID" />
</key>
<one-to-many
class="com.kohls.pm.pp.common.entity.PermEventMerchandiseSelection"
/>
</bag>
<!-- bi-directional many-to-one association to PetEvntCtg -->
<many-to-one
name="category"
lazy="false"
class="com.kohls.pm.pp.common.entity.PermPriceChangeEventCategory"
not-null="true"
>
<column name="EVNT_CTG_CDE" />
</many-to-one>

</class>
</hibernate-mapping>

Let me know if you need additional associated mappings.

Code between sessionFactory.openSession() and session.close():
session.save(object); NOTE: this is when exception happens = BaseDao.java:289
session.flush();

Full stack trace of any exception that occurs:
org.hibernate.MappingException: Unknown entity:
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(Ljava.lang.String;)Lorg.hibernate.persister.entity.EntityPersister;(SessionFactoryImpl.java:513)
at org.hibernate.impl.SessionImpl.getEntityPersister(Ljava.lang.String;Ljava.lang.Object;)Lorg.hibernate.persister.entity.EntityPersister;(SessionImpl.java:1321)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(Ljava.lang.Object;Ljava.lang.String;Ljava.lang.Object;Lorg.hibernate.event.EventSource;)Ljava.io.Serializable;(AbstractSaveEventListener.java:89)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(Lorg.hibernate.event.SaveOrUpdateEvent;)Ljava.io.Serializable;(DefaultSaveOrUpdateEventListener.java:186)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(Lorg.hibernate.event.SaveOrUpdateEvent;)Ljava.io.Serializable;(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(Lorg.hibernate.event.SaveOrUpdateEvent;)Ljava.io.Serializable;(DefaultSaveOrUpdateEventListener.java:175)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(Lorg.hibernate.event.SaveOrUpdateEvent;)Ljava.io.Serializable;(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(Lorg.hibernate.event.SaveOrUpdateEvent;)V(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(Lorg.hibernate.event.SaveOrUpdateEvent;)Ljava.io.Serializable;(SessionImpl.java:559)
at org.hibernate.impl.SessionImpl.save(Ljava.lang.String;Ljava.lang.Object;)Ljava.io.Serializable;(SessionImpl.java:547)
at org.hibernate.impl.SessionImpl.save(Ljava.lang.Object;)Ljava.io.Serializable;(SessionImpl.java:543)
at com.kohls.pm.pp.server.dao.BaseDao.insert(Ljava.lang.Object;)V(BaseDao.java:289)

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):
Modified, right before insert sql is generated (does not show)
select * from K_PE01.PET_PERM_EVNT where EFF_DTE=? and EVNT_CTG_CDE=? and STAT_CDE in (?, ?)
select * from K_PE01.PET_PERM_EVNT where this_.EFF_DTE=? and STAT_CDE in (?, ?)
EXPECTING INSERT SQL HERE!

Debug level Hibernate log excerpt:

*********************************************************************


Last edited by wiphillyfan on Thu Feb 16, 2006 5:45 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: session.save(obj) using Interceptor v3.1.2 change?
PostPosted: Thu Feb 16, 2006 5:45 pm 
Beginner
Beginner

Joined: Thu Jun 23, 2005 10:23 pm
Posts: 22
Figured out that, due to the use of an interceptor, I have to add the entityName as a param to save() (at least for hiber ver 3.1.2)

This code worked fine in 2.0:
session = HibernateUtil.getSession(getInterceptor());
session.save(object);
session.flush();

But 3.1.2 - got around the 'MappingException: Unknown entity' stated above by doing:
session = HibernateUtil.getSession(getInterceptor());
session.save(object.getClass().getName(), object);
session.flush();

Not sure why the change or if this is an issue - probably documented somewhere but I have not run across it.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.