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.
|