Regular |
|
Joined: Thu Dec 18, 2003 2:14 am Posts: 103 Location: Brooklyn, NY
|
Hibernate version:
2.1.7
Mapping documents:
USER:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.martin.model" >
<class name="com.martin.model.User" table="users" discriminator-value="null" lazy="true">
<cache usage="read-write" />
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="increment"/>
</id>
<discriminator column="type_id" type="integer" />
<property name="username" type="string" column="username" not-null="false" unique="true" />
<property name="password" type="string" column="password" not-null="false" unique="false" />
<property name="firstName" type="string" column="first_name" not-null="false" unique="false" />
<property name="lastName" type="string" column="last_name" not-null="false" unique="false" />
<property name="email" type="string" column="email" not-null="false" unique="false" />
<property name="street" type="string" column="street" not-null="false" unique="false" />
<property name="state" type="string" column="state" not-null="false" unique="false" />
<property name="zipcode" type="string" column="zipcode" not-null="false" unique="false" />
<property name="phone" type="string" column="phone" not-null="false" unique="false" />
<property name="active" type="boolean" column="active" not-null="true" unique="false" />
<property name="guid" type="string" column="guid" not-null="false" unique="true" />
<property name="registered" type="java.util.Date" column="registered" not-null="false" unique="true" />
<many-to-one name="serialNumber" class="com.martin.model.SerialNumber" column="serial_number_id" not-null="false" unique="true" />
<subclass name="com.martin.model.Admin" discriminator-value="3" lazy="true">
</subclass>
<subclass name="com.martin.model.Teacher" discriminator-value="1" lazy="true" >
<many-to-one name="school" class="com.martin.model.School" column="school_id" />
<!--inverse="true" means that Course is responsible for the relation-->
<set name="courses" inverse="true" lazy="true">
<key column="teacher_id"/>
<one-to-many class="com.martin.model.Course"/>
</set>
<set name="activeCourses" inverse="true" lazy="true"
where="active='true'">
<key column="teacher_id"/>
<one-to-many class="com.martin.model.Course"/>
</set>
<set name="inactiveCourses" inverse="true" lazy="true"
where="active='false'">
<key column="teacher_id"/>
<one-to-many class="com.martin.model.Course"/>
</set>
</subclass>
<subclass name="com.martin.model.Student" discriminator-value="2" lazy="true" >
<many-to-one name="course" class="com.martin.model.Course" column="course_id" />
<!--inverse="true" means that Homework is responsible for the relation-->
<map name="homework" table="homework" lazy="true" cascade="all-delete-orphan">
<key column="student_id"/>
<index column="assignment_id" type="long"/>
<one-to-many class="com.martin.model.Homework"/>
</map>
</subclass>
</class>
</hibernate-mapping>
SERIAL NUMBER
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="com.martin.model" >
<class name="com.martin.model.SerialNumber" table="serial_numbers" lazy="true">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native">
<param name="sequence">serial_numbers_id_seq</param>
</generator>
</id>
<property name="serialId" type="long" column="serial_id" not-null="false" unique="true" />
<property name="typeId" type="int" column="type_id" not-null="false" unique="false" />
<property name="expires" type="date" column="expires" not-null="false" unique="false" />
<property name="registered" type="boolean" column="registered" not-null="false" unique="false" />
<many-to-one name="module" class="com.martin.model.Module" column="module_id" />
<one-to-one name="user" class="com.martin.model.User" property-ref="serialNumber" />
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
WARNING: Unable to perform background process on manager
java.lang.ClassCastException: cannot assign instance of net.sf.hibernate.proxy.SerializableProxy to field com.martin.model.base.BaseUser._serialNumber of type com.martin.model.SerialNumber in instance of com.martin.model.Teacher
at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1885)
at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1076)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1851)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1338)
at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:882)
at org.apache.catalina.session.FileStore.load(FileStore.java:289)
at org.apache.catalina.session.StoreBase.processExpires(StoreBase.java:216)
at org.apache.catalina.session.PersistentManagerBase.backgroundProcess(PersistentManagerBase.java:227)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:4618)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1619)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608)
at java.lang.Thread.run(Thread.java:552)
Name and version of the database you are using:
Postgres 7.4
Issue
I'm trying to persist sessions over a Tomcat 5 restart, and cannot because the SerialNumber field of the User class will not load. A ClassCastException is thrown casting SerializableProxy to SerialNumber. Is the SerializableProxy getting rehydrated, but forgetting what it is supposed to be acting as?
thanks for any help,
Michael Greer
|
|