-->
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.  [ 5 posts ] 
Author Message
 Post subject: "could not determine type of dynamic entity"
PostPosted: Tue Nov 18, 2008 3:30 pm 
Newbie

Joined: Fri Nov 14, 2008 4:07 pm
Posts: 6
Hi, I have a very simple class as follows:

public class MyClass implements Map<String, Object> {

private int mId;

public ABID getUid()
{
return mId;
}

public void setUid(ABID id)
{
mId = id;
}
}

Okay, I know it's weird to implement Map interface, I'm dealing with lots of legacy code(this is a simplified class) and I can't change them.

mapping file as follows:
<hibernate-mapping package="com.apldbio.sds.platform.core.security">
<class name="User" table="user" lazy="false">
<id column="id" name="id">
<generator lass="native"/>
</id>
</class>
</hibernate-mapping>

I can successfully create schema using SchemaExport, however when I try to call update using spring


getHibernateTemplate().saveOrUpdate(user);
The following exceptions thrown:


org.springframework.orm.hibernate3.HibernateSystemException: could not determine type of dynamic entity; nested exception is org.hibernate.HibernateException: could not determine type of dynamic entity
Caused by: org.hibernate.HibernateException: could not determine type of dynamic entity
at org.hibernate.impl.SessionImpl.guessEntityName(SessionImpl.java:1797)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1365)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203)


i noticed that if I remove "implements Map" from User class, everything will be fine.

But the question is that I'm using "property" access mode and all hibernate should care about is getters and setters, where is that exception coming from?

Anybody has experienced this before? Any help is appreciated.

Eddie


Top
 Profile  
 
 Post subject: Wrong class name
PostPosted: Tue Nov 18, 2008 3:32 pm 
Newbie

Joined: Fri Nov 14, 2008 4:07 pm
Posts: 6
Sorry my mistake, typo

class name is User

public class User implements Map<......

It was my typo writing this post


Top
 Profile  
 
 Post subject: wrong again
PostPosted: Tue Nov 18, 2008 3:33 pm 
Newbie

Joined: Fri Nov 14, 2008 4:07 pm
Posts: 6
This is the correct User class

public class User implements Map<String, Object> {

private int id;

public ABID getId()
{
return id;
}

public void setId(ABID id)
{
this.id = id;
}
}


Top
 Profile  
 
 Post subject: Really sorry
PostPosted: Tue Nov 18, 2008 3:35 pm 
Newbie

Joined: Fri Nov 14, 2008 4:07 pm
Posts: 6
public class User implements Map<String, Object> {

private int id;

public ABID getId()
{
return id;
}

public void setId(int id)
{
this.id = id;
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 25, 2009 1:54 pm 
Newbie

Joined: Sun Jan 25, 2009 12:27 pm
Posts: 1
I encountered this same problem. The issue is that Hibernate is automatically trying to use "dynamic entity mode" because your class implements Map. Hibernate's logic goes like this...

Code:
String entityName = interceptor.getEntityName(object);
if (entityName == null) {
   if (object instanceof Map) {
      // Use dynamic entity mode
   } else {
      entityName = object.getClass().getName();
   }
}


The solution I used was to set a Configuration level Interceptor (that extends EmptyInterceptor) to check for my special case:

Code:
public String getEntityName(Object object) {
   if (object != null && object instanceof MyClassThatImplementsMap) {
       return object.getClass().getName();
   } else {
       return super.getEntityName(object);
   }
}


This completely solved the problem!

Here's a link to the relevant Hibernate documentation:
http://www.hibernate.org/hib_docs/refer ... vents.html

Hope this helps!


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