-->
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: Hibernate 3.x Best practicies in J2EE Container
PostPosted: Wed Dec 28, 2005 5:35 am 
Newbie

Joined: Wed Dec 28, 2005 4:57 am
Posts: 1
Hi, recently bought the manning book and read myself up to a beginner level on hibernate as Im using it to implement a persistent domain model for a customer. I've got previous experience with EJB 2.x Enitity beans and CRM/CMP and found a lot of similarities...

My application will be a struts/JSP application that works as an admin interface to data in an Oracle database. Im using a Oracle 10g Application server as well.

I really want to use CMT. (Container managed transactions), and declarative transaction demaraction.

0. Is the "simple" HibernateUtil (from Caveatemptor) most suitable for J2EE/EJB settings? Is keeping the session in a thread local variable suitable for Container code ?

1. How do I write business code that can run in the container, and be
tested in a "local" test harness using HSQLDB / Junit ? The container code does currently *Not* use the Hibernate transaction API (explicit commit/rollback). My Business objects look like this ;

public void someBusinessmethod() {

Session session = sessions.currentSession() ;
session.saveOrUpdate(...)

}

No flush, no commit, no rollback. All handled by the container/JTA. However, when unit testing my Business method, I run the test on my local computer and have no container. How can one solve this issue?
Some DAO/BO design pattern might solve this, any best practices ?
I don't want (and are not paid) to re-invent any wheels here.

2. I also use plan on using the (anti) pattern session-per-request, meaning that an http request hits the servlet engine (for example the first page of the application).

1. The servlet requests data from the EJB session facade
2. A hibernate sessoion is started
3. Data is fetched
4. Session is closed
5. Data is returned
6. Data displayed in the web GUI.

Is this considered bad ? don't really see any point of using "application transactions" in my case.

Some insight, and real life experience would be most welcome !

Best regards a and happy hollidays to all of you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 8:05 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://hibernate.org/42.html
http://hibernate.org/43.html


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.