-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session is closed error while creating entities
PostPosted: Fri Jul 30, 2004 2:26 am 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
I am trying to load data into database tables from an XML feed.

TABLE structure is a follows:

tbl_movie
Code:
id
name
...


tbl_venue
Code:
id
name
street
...


tbl_event
Code:
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


Top
 Profile  
 
 Post subject: Cascade = 'delete'
PostPosted: Fri Jul 30, 2004 2:47 am 
Newbie

Joined: Mon Jun 14, 2004 5:16 pm
Posts: 16
Location: New York
I figured what the problem is.
Event object was contacting a DAO object to lookup Movie and Venue objects. DAO object was opening a thread object session to perform the lookup and then closing the session.

The problem is now with the delete operation. When Venue and Movie entities are deleted Event records are not deleted eventhough cascade is set to 'delete' in Event.hbm.xml..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.