-->
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.  [ 1 post ] 
Author Message
 Post subject: How to get jdbc connection in Hibernate 4
PostPosted: Fri Jul 13, 2012 3:11 am 
Newbie

Joined: Fri Jul 13, 2012 2:54 am
Posts: 1
Hi guys, I am having a couple of questions based on Hibernate 4 use.

1. In Hibernate 3, we can get jdbc connection with following code
Code:
ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(properties);
Connection connection = connectionProvider.getConnection();

These classes and apis have been duplicated in Hibernate 4. So the question is how to get the connection in Hibernate 4.

2. Another similar question is how to get a jdbc connection by a given session? In Hibernate 3, it is easy to get a connection by session.connection() method. I know there is a session.doWork() method but it only does things in the execute() method. How can I get the connection and use it outside of the execute() method?

3. When I am modifying some jbpm 3.1.4's source codes to work with Hibernate 4 (originally jbpm 3.1.4 worked with Hibnerate 3), I got this error messag when the jbpm is trying to close its resources:
Code:
No value specified for parameter 2

Can anybody give me some clue where I may get it wrong when modifying the codes? The most important place I have modified should be the method of getting connection. Originally it used session.connection() to get the connection directly but now I am using
Code:
Work work = new Work()
{
public void execute (Connection conn)
{
   myConnection = conn;
}
};
session.doWork();
return myConnection;

This way to return a conection outside of execute method should be wrong, but I have not found evidence to confirm if this error is related to this change.

Much appreciated if someone can provide some ideas on how to resolve my issues above.


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

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.