I have 3 tables:
tbl_movie
Code:
id
name
...
tbl_theaterCode:
id
name
adress
...
tbl_eventCode:
id
movie_id
even_id
price
date
....
and I have 3 corresponding classes, Movie, Theater and Event
What I'm trying to do is to make sure
everytime I load a Movie, it comes with set of theaters it plays in, and vice versa for Theater.
So basically, everytime a Movie is loaded, find the mapping entries in the
tbl_event and through those records load the Theater objects.
In Theater I have:
Code:
List movies
and Theater.hbm.xml contains:
Code:
<bag
name="movies"
table="tbl_event"
lazy="false"
inverse="false"
cascade="none"
>
<key
column="theater_id"
>
</key>
<element
column="movie_id"
type="Movie"
not-null="false"
unique="false"
/>
</bag>
and in Movie similarly:
Code:
List theaters
and the Movie.hbm.xml contains:
Code:
<bag
name="theaters"
table="tbl_event"
lazy="false"
inverse="false"
cascade="none"
>
<key
column="movie_id"
>
</key>
<element
column="theater_id"
type="Venue"
not-null="false"
unique="false"
/>
</bag>
When I try to load the Theaters, say, by their zipcode:
Code:
Query query = session.createQuery("from " + Theater.class.getName()
+ " venue where theater.address.postcode like :zip "
+ " order by theater.address.postcode, " + " theater.name");
query.setParameter(...,...);
I get the following error:
net.sf.hibernate.type.SerializationException: could not deserialize
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:197)
at net.sf.hibernate.util.SerializationHelper.deserialize(SerializationHelper.java:220)
at net.sf.hibernate.type.SerializableType.fromBytes(SerializableType.java:73)
at net.sf.hibernate.type.SerializableType.get(SerializableType.java:38)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.collection.AbstractCollectionPersister.readElement(AbstractCollectionPersister.java:363)
at net.sf.hibernate.collection.Bag.readFrom(Bag.java:75)
at net.sf.hibernate.loader.Loader.readCollectionElement(Loader.java:305)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:219)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:83)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3264)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3119)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
Code:
Aug 2, 2004 5:57:58 PM WARNING: Unable to run query: net.sf.hibernate.type.SerializationException: could not deserialize
All classes implement Serializable and have default constructors...
What am I doing wrong here?
Thanks in advance,
Cagan