-->
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.  [ 4 posts ] 
Author Message
 Post subject: Alter Database Session
PostPosted: Tue Apr 01, 2008 10:16 am 
Newbie

Joined: Tue Apr 01, 2008 9:14 am
Posts: 3
After I start a session with my database using sessionFactory, what is the proper way to issue an alter session command against the database?

Specifically, I am trying to change the time zone that the session is using on the fly. If I was doing this against Oracle through a regular query tool like TOAD, I would connect to the database, and then run the command:

alter session set TIME_ZONE='-03:00';


So how do I do that through hibernate?

Note: I realize this may be a simple question, but I have searched through the documentation over and over and I just keep missing it. Please end my confusion and my fruitless searching. Thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2008 5:09 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
The best way to do this is typically through your data source. Most (Apache DBCP, JBoss, probably others) offer a setting for "new connection SQL" or similar. A way to run SQL on every new connection that is opened.

Failing that, you can always subclass ConnectionProvider and add a little behavior to getConnection(). ConnectionProvider is pluggable via programmatic or XML configuration.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 12:20 pm 
Newbie

Joined: Tue Apr 01, 2008 9:14 am
Posts: 3
Thanks for your advice. We are using JBoss for this application and will slide this little piece of code in there. So this will work nicely for us.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 1:13 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
Not sure which recommendation you're talking about, but if you are using JBoss, you need only configure a <new-connection-sql> element in your DataSource descriptor. No code required!

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


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