I am trying to load data into database tables from an XML feed.
TABLE structure is a follows:
tbl_movie
Code:
id
name
...
tbl_venueCode:
id
name
street
...
tbl_eventCode:
id
movie_id
venue_id
pricing_info
time_info
...
And 3 respective java classes:
Code:
Venue
Movie
Event
the mapping in Event.hbm.xml is as follows for the many-to-one associations:
Code:
<many-to-one
name="movie"
class="Movie"
cascade="delete"
outer-join="auto"
update="true"
insert="true"
access="property"
column="movie_id"
/>
<many-to-one
name="venue"
class="Venue"
cascade="delete"
outer-join="auto"
update="true"
insert="true"
access="property"
column="venue_id"
/>
....
I specified cascade as 'delete' as I want Events to be deleted when a Movie and/or a Venue they refer to is deleted.
I have an XML file that contains all movie, venue and event listings. I process the xml in the following order (same transaction):
Movies
Venues
Events...
Movies and Venues get loaded properly, but when I try to load the first
Event, I get the following exception:
Code:
net.sf.hibernate.HibernateException: Session is closed
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3288)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:109)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:460)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.executeInserts(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
I'd appreciate your help on this.
Thanks,
Cagan