-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to dynamically change database user?
PostPosted: Wed Aug 15, 2007 1:19 pm 
Newbie

Joined: Wed Aug 15, 2007 1:12 pm
Posts: 1
I want to use hibernate with an existing database. The problem is that there are multiple database accounts with different privileges, and my application must dynamically switch to the appropriate database user based on what it is doing and for whom? At the JDBC level, I want to be calling getConnection passing in a database username and password. How can I communicate these values to the Hibernate DAO?

Thanks,
Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 5:42 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Sounds like you need to create multiple session factories with different username/password configs. Then choose the session factory appropriate for your user/operation in your DAO.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 16, 2007 6:22 am 
Regular
Regular

Joined: Wed Oct 15, 2003 4:40 pm
Posts: 67
I'm also interested in this, mainly in the JPA context.

There is the DataSource.getConnection(username, password) but when using JPA, is there any way of doing a run-time change of the database user?

EntityManagerFactory has a setPersistenceUnitProperties(Map) but that is probably at too high a level(?)

aTdHvAaNnKcSe,
-Nik


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