This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I managed to integrate struts with spring and i've created my UserService, no problems thus far.
Now comes the tricky part, i want to make hibernate connect to the database with the username and password supplied in the login page. From what i understand from that tutorial, spring manages behind the scenes the configuration and initialisation of hibernate and then it injects a EntityManager object into my UserService.
So my question is this, is there any way to programatically configure each instance of hibernate within struts ? Or are there any alternatives i can use ? [ November 06, 2008: Message edited by: D. David ]
The Hibernate docs describe many ways to connect to a DB via Hibernate, including programmatically. What specific issues are you having?
(Technically this is a purely Hibernate question; as such, it might be better asked in a Hibernate forum
Joined: Nov 06, 2008
Thanks for the answer, well i wasn't sure where to put the topic since i'm having touble with integrating struts with hibernate so i figured it might be a struts questions.
Well the thing is that from what i've read so far when i'm trying to use hibernate with struts i have to let the struts spring plug-in initialize a EntityManager object and inject it in my UserService. And i do this by writing this in the applicationContext.xml:
As you can see i specify here the username and password with which the connection to the database should be made. What i want to do is to have a form on the first page from which i get my username and password and to use those to connect to the database.
That's certainly the typical scenario--normally a web application will have a single database user (in fact I haven't seen otherwise in 10 years). It's not a requirement, though--if you're not going to go that route then following the regular Hibernate documentation should work fine.
subject: How to programatically configure hibernate from struts 2?