Hibernate version:3-0
Hi, I've created simple dynamic model using dynamic-map.
There are only two entities connected with one-to-many relation.
this is my mapping file:
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test">
<class entity-name="User" table="user">
<id name="id"
type="int"
column="id">
<generator class="increment"/>
</id>
<property name="name"
column="name"
type="string"/>
<many-to-one name="city" column="city_id" entity-name="City" lazy="true"/>
<many-to-one name="place" column="place_id" entity-name="Place" lazy="true"/>
</class>
<class entity-name="City" table="city">
<id name="id"
type="int"
column="id">
<generator class="increment"/>
</id>
<property name="name" lazy="true"
column="name"
type="string"/>
<bag name="users" lazy="true" inverse="true"
cascade="all">
<key column="city_id"/>
<one-to-many entity-name="User"/>
</bag>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
I heve one stateless session bean and one remote method(created only for simple test), which looks like the following:
public List getUsers() {
Session session = factory.openSession();
List l = session.createCriteria("User").list();
return l;
}
(Sessionfactory has "hibernate.default_entity_mode" property set to "dynamic-map")
Full stack trace of any exception that occurs:
when i work with retrieved by hibernate data inside my session bean, everything works great. Only when I invoke described remote method in my client program exception is thrown :
java.lang.reflect.UndeclaredThrowableException
at $Proxy1.getData(Unknown Source)
at test.client.Main.main(Main.java:33)
Caused by: java.io.InvalidClassException: org.hibernate.proxy.MapLazyInitializer; no valid constructor
at java.io.ObjectStreamClass.<init>(Unknown Source)
at java.io.ObjectStreamClass.lookup(Unknown Source)
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.HashMap.readObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.util.ArrayList.readObject(Unknown Source)
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 java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.rmi.MarshalledObject.get(Unknown Source)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:136)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:87)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
... 2 more
this error appears while serializing MapLazyInitializer. When I've changed MapLazyInitializer constructor to public, this problem has disappeared.
Name and version of the database you are using:
MySql 4.0.20d
|