-->
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.  [ 6 posts ] 
Author Message
 Post subject: Example servlet skeleton
PostPosted: Wed Sep 22, 2004 2:08 pm 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
Hi hibernators,

I am about to create a servlet that uses Hibernate via the helper class "HibernateUtil" and I am confused about exactly how I am supposed to initialize the HibernateUtil class so it creates the session factory and then how to make use of it. I have searched quite a bit for an example and I always come up with nothing. I am referring to the HibernateUtil class as defined here: http://www.hibernate.org/hib_docs/refer ... start.html

If someone could post a link to a good example of how to make use of this (full code, not just what's in between opensession and closesession) I would be very appreciative! Thanks!
-Eric


Top
 Profile  
 
 Post subject: Try xPetStore
PostPosted: Wed Sep 22, 2004 3:46 pm 
Newbie

Joined: Mon Sep 20, 2004 10:27 am
Posts: 7
Try looking for xPetstore , they have Servlet example using Hibernate

http://xpetstore.sourceforge.net/

_________________
Rgds,

--Siva Jagadeesan
Application Developer
ThoughtWorks, Inc


Top
 Profile  
 
 Post subject: No frameworks
PostPosted: Wed Sep 22, 2004 5:11 pm 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
Thanks for the tip. I checked it out, but it seems like a complex example. I'm surprised that I couldn't find any easy examples. I come across lots of examples that use frameworks like struts, but nothing that is just plain old servlets with hibernate. Is this because very few people do things this way?
-E


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 22, 2004 5:45 pm 
Newbie

Joined: Wed Sep 22, 2004 10:10 am
Posts: 15
Location: Darmstadt, Germany
I have a (very) simple application here consisting of a controller servlet, a few jsps for the View and a few POJOs:
www.purplemachine.de/downloads/csm/hibernateSample.zip

It was only my second hibernate application, but maybe this will help you.

Best regards,

Thorsten


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 25, 2004 10:36 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
The HibernateUtil class uses a very simple and effective static initializer block to do the SessionFactory init. Try Google for "java static initializer".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Mon Sep 27, 2004 10:05 am 
Newbie

Joined: Wed Sep 22, 2004 2:01 pm
Posts: 9
Thanks for all your help! I've gotten things rolling.
-E


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