-->
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.  [ 8 posts ] 
Author Message
 Post subject: Problem upgrading to Hibernate 3.0.5
PostPosted: Wed Jul 27, 2005 4:00 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
I'm upgrading a project to Hibernate 3.0.5 (and Spring 1.2.1). So far, things are going reasonably well, but now I'm down to seeding a database with domain data and encountering some issues. I'm getting a MappingException, but can't find the cause. I have to assume that there is some change in the mapping file syntax or API that I've overlooked. I'm hoping someone may be familiar with this because I haven't been able to find that elusive change. The exception stack is below.
Thanks,
Dave


Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: Internal Event Creator; nested exception is org.hibernate.MappingException: Unknown entity: Internal Event Creator
org.hibernate.MappingException: Unknown entity: Internal Event Creator
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:569)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1086)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:83)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:541)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:538)
at com.enttek.ems.server.dao.EmsDao.save(EmsDao.java:110)
at com.enttek.ems.shared.model.SeedDomainData.SeedUserTypes(SeedDomainData.java:95)
at com.enttek.ems.shared.model.SeedDomainData.SeedData(SeedDomainData.java:59)
at com.enttek.ems.shared.model.SeedDomainData.main(SeedDomainData.java:39)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 9:49 am 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
Still stuck on this problem. Here is my mapping file for the entity that is receiving the exception in case that is helpful, but it's pretty vanilla. It seems that it doesn't matter what entity I choose to try to save first, though, I get the same exception.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
>
<class
name="com.enttek.ems.shared.model.UserType"
table="user_type"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>

<id
name="id"
column="id"
type="java.lang.Long"
>
<generator class="native"/>
</id>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"
not-null="true"
/>

<property
name="code"
type="char"
update="true"
insert="true"
access="property"
column="code"
not-null="true"
/>

<property
name="isSalesRegion"
type="boolean"
update="true"
insert="true"
access="property"
column="is_sales_region"
/>

<property
name="modifiedTimestamp"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="modified_timestamp"
not-null="true"
/>

<property
name="createdTimestamp"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="created_timestamp"
not-null="true"
/>

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 10:51 am 
Regular
Regular

Joined: Thu May 26, 2005 2:08 pm
Posts: 99
It appears that it's trying to save an entity named "Internal Event Creator". I'd start tracing this with a debugger and figure out where that name is coming from.

Posting some Java code wouldn't hurt either.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 11:08 am 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
"Internal Event Creator" is the toString() result from the UserType object that I'm trying to save. Apparently, the exception calls toString() on the object in question when creating its message. "UserType", in this case, is not the Hiberrnate UserType class, but rather a domain entity in our software.

By turning on debugging, I can see that Hibernate knows the object is transient. That's really all I know right now.

I'm trying to chop down my project into a small test case with one entity so that I can hopefully narrow down the problem.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 12:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
Apparently, the exception calls toString() on the object in question when creating its message

absolutely not.

Either one of two things is happening:
1) You call the session.save(String entityName,Object entity) form instead of session.save(Object entity) and pass in UserType.toString() as the entityName
2) You use an Interceptor, which is returning UserType.toString() from its getEntityName() implementation.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 2:54 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
Yes, there is an interceptor, and it is returning the toString() implementation of the object in the getEntityName() method. I really wasn't sure what I should do with that method since it was new to me.

I finally managed to trace the problem down into the hibernate source and discovered that my new object (which I would have thought of previously as "transient") is being thought of as "detached". So then hibernate attempts to update the object instead of save it. So, I know now why I get an exception, but I don't know why it thinks my object is detached and not transient.

Thanks for the feedback.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 3:50 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
A little more detail now.

Looks like during the processing of the save(entity) call, there is no entityName available, so no persister can be found to work with it. I did fix a problem in my interceptor that was returning FALSE for isTransient().


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 4:08 pm 
Beginner
Beginner

Joined: Fri Jun 10, 2005 2:22 pm
Posts: 27
Ok, looks like I managed to get her working finally. The problem was in the interceptor. I guess the isTransient() and getEntityName() methods are much more important than they first appeared to be.

I also discovered the EmptyInterceptor class which makes a good base class so that you don't have to implement all those methods that you don't care about overriding.

Thanks for all the feedback - whether it seems like it or not it was helpful.
Dave


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