-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate leaving prepared statements open...JBoss exception
PostPosted: Wed Apr 07, 2004 3:48 pm 
Beginner
Beginner

Joined: Mon Feb 09, 2004 3:15 pm
Posts: 34
Here's my code:
Code:
Session session = null;

try {
    session = openSession();

    while(interests.hasNext()) {
        PStatUserSelection answer = (PStatUserSelection) interests.next();
        session.save(answer);
    }

    session.flush();

} finally {
    closeSession(session);
}



Here's the exception:
Code:
14:43:15,546 WARN  [WrappedConnection] Closing a statement you left open, please do your own houseke
eping
java.lang.Exception: STACK TRACE
        at org.jboss.resource.adapter.jdbc.WrappedConnection.registerStatement(WrappedConnection.jav
a:805)
        at org.jboss.resource.adapter.jdbc.WrappedStatement.<init>(WrappedStatement.java:43)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.<init>(WrappedPreparedStatement.
java:51)
        at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java
:211)
        at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:249)
        at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
        at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
        at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:505)
        at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
        at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:
29)
        at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
        at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
        at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
        at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)


My question: why?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 4:52 pm 
Beginner
Beginner

Joined: Mon Feb 09, 2004 3:15 pm
Posts: 34
I am actually noticing that all of my calls to save() and saveOrUpdate() are now throwing this exception. The only thing i've changed recently is the hibernate jar file, i upgraded to the latest version.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 5:28 pm 
Beginner
Beginner

Joined: Mon Feb 09, 2004 3:15 pm
Posts: 34
Ok, i'm starting to narrow it down. I only get the error when Hibernate issues INSERT statements.

So basically Hibernate is leaving the prepared statements open when inserting into the DB.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Looks like you might be right.

Let me guess: you are using SQL server or sybase, and identity columns?

Looks like a recent patch breaks preparedstatement handling in that case.

I'll try to get 2.1.3 out as soon as possible now then.

You'll find the fix in CVS.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:09 pm 
Beginner
Beginner

Joined: Mon Feb 09, 2004 3:15 pm
Posts: 34
I'm using SQL Server and identity columns.

Good guess :-)

Will grab the latest from CVS. Thanks for responding.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 8:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, a trivial workaround on affected platforms should simply be to set

Code:
hibernate.jdbc.use_get_generated_keys=true


(Assuming the driver supports JDBC3.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.