-->
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.  [ 7 posts ] 
Author Message
 Post subject: Connection problem
PostPosted: Wed Sep 06, 2017 7:11 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
When I execute a session.connection.commit the next execution "java.sql.SQLException: You can't operate on a closed Connection!!!"

I use this because I need execute commit part of the process. And execute new query.

I use "hibernate-c3p0-5.2.10.Final.jar". If I remove this jar, don't have error.


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Wed Sep 06, 2017 12:13 pm 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
If I use Hibernate 5.1.10 the problem does't exist. Any Ideia?


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Wed Sep 06, 2017 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Without seeing the data access logic, it's impossible to figure out the problem.


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Thu Sep 07, 2017 4:32 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
The code is the same, only change hibernate version.

I have a hibernate session create with standard options.

Execute multiple select and inserts with prepareStatement.

Next execute :
session.connection.commit();

I try exeecute a new query with prepareStatement that give the error:
java.sql.SQLException: You can't operate on a closed Connection!!!

I don't close the session after commit.

It's work equal if I user HQL.

If I use Hibernate 5.1.10 work fine, and if I use 5.2.10 and remove hibernate-c3p0-5.2.10.Final.jar work fine too.

With all far of 5.2.10 get the error.


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Thu Sep 07, 2017 5:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
There is no session.connection in Hibernate 5. That got removed in 4.x.

If you are talking about:

Code:
session.getTransaction().commit();


Then you need to call:

Code:
session.getTransaction().begin();


after you ended the previous transaction.


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Fri Sep 08, 2017 11:04 am 
Newbie

Joined: Tue Aug 29, 2017 6:03 am
Posts: 11
I need commit a session without close the transaction.

I use "((SessionImpl)getSession()).connection().commit()"

How I can execute the same?


Top
 Profile  
 
 Post subject: Re: Connection problem
PostPosted: Fri Sep 08, 2017 11:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Code:
((SessionImpl)getSession()).connection().commit()


I suppose you are using Hibernate 3. That API has long been removed from Hibernate, and neither 3.x or 4.x are supported anymore.

Quote:
I need commit a session without close the transaction.


You confuse how the Session and the transaction handling are supposed to work. You should read the new User Guide to get a better understanding of how these two concepts relate.


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