-->
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: Executing custom setup SQL on each connection before use
PostPosted: Thu Nov 27, 2003 10:39 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
We want to run some custom SQL on each connection before Hibernate uses the connection.

The SQL only needs to be run once for each connection, it doesn't matter if the connection is involved in lots of transactions (ie. used in a connection pool), as long as the SQL got executed before the first transaction was executed.

Currently, I've subclassed the ProxoolConnectionProvider and overridden the getConnection() method to execute the SQL we need executed before returning the new connection.

There are two problems with this approach:
1. The sql ends up being executed on the same connection multiple times, it's not thta big a deal since the SQL is just setting up the environment and doesn't take too long to execute, but it does take time and it clutters up the SQL log.

2. This one's not that big a deal, just annoying - It only works as long as we are using Proxool for our connection pool, if we decide to switch to a difference connection pool, we'll have to write another custom ConnectionProvider.

Is there any better way to do this? What we're doing now is functional, it works, I'm just wondering if there's a different way to do this?

The version of Hibernate 2.1 beta 6.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 10:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think this is the best way


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.