-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate4 dynamic-map issue
PostPosted: Wed Jul 04, 2012 10:33 pm 
Newbie

Joined: Wed Jul 04, 2012 10:13 pm
Posts: 2
Hi,

We are migrating from hibernate3 to hibernate4.We are facing problem with dynamic-map configuraiton in hibernate4.
Here is the sample code.
//Session session = getSession().getSession(EntityMode.MAP);
Session session = getSession();
Transaction transaciton = session.beginTransaction();
session.save("Branch", map);
In hibernate3 Session API support to this method getSession().getSession(EntityMode.MAP).Since it is experimental they removed in Hibernate4.

But the other provision to handle this is to set the configuration parameter at SessionFactory level file like below in cfg file.
<property name="hibernate.default_entity_mode" >dynamic-map</property>

After this setup applicaiton is throwing the below Exception.

Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of hibernate.dynamicmap.GenericData.id
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:119)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:381)
at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:4328)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:183)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:136)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:757)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:749)
at hibernate.dynamicmap.Main.saveMap(Main.java:19)
at hibernate.dynamicmap.Main.main(Main.java:48)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:65)
... 13 more

The issue is because setter/getters are executing on map that i'm passing as part of the session.It seems the session factory is not recognizing the dynamic-map configuration.

Any lights on this will help me.Thanks in advance.


Regards,
Ravi.


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

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.