-->
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.  [ 5 posts ] 
Author Message
 Post subject: architecture question
PostPosted: Thu Jan 13, 2005 10:58 am 
Beginner
Beginner

Joined: Thu Jan 13, 2005 10:31 am
Posts: 20
Hibernate version: 2.17c

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

I am working on building a web application and want to use Hibernate. The architecture I think will be JSP --> Business Delegate --> Session Facade --> DAOs --> POJOs --> Database. Is it the recommended approach?

I have build the POJOs and mapping files. Now I am thinking about building DAOs. My question is should I build these DAOs as Stateless Session Beans or just simple java files? Also I am thinking about using POJOs to pass data from server to client. Will I get into any problems with this approach?


Please throw any answer at me. I really appreciate it.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 11:22 am 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
with Hibernate I think you dont need DAOs. Instead you can build Stateless Session Beans for each use case you have in your application.

JSP --> Business Delegate --> Session Facade --> POJOs --> Database


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 1:18 pm 
Beginner
Beginner

Joined: Thu Jan 13, 2005 10:31 am
Posts: 20
Quote:
JSP --> Business Delegate --> Session Facade --> POJOs --> Database


Dont you mean ?

JSP --> Business Delegate --> Session Facade --> Stateless Session Beans --> POJOs --> Database


why not use DAOs?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 2:25 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
Intermixing business logic with Hibernate API calls is not a good design choice, IMO. DAOs serve a very useful purpose in isolating persistence (Hibernate) logic from business logic.

There are lots of ways to structure Hibernate-based apps. The one our organization uses pairs Hibernate (for persistence) with Spring (for transactions and config management). Here's a good article:

http://hibernate.bluemars.net/110.html

This one is okay, too:

http://www.onjava.com/pub/a/onjava/2004 ... bapps.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
Intermixing business logic with Hibernate API calls is not a good design choice, IMO. DAOs serve a very useful purpose in isolating persistence (Hibernate) logic from business logic.


of course, use DAO. Just one example swithing from hibernate 2 to hibernate 3 need to change all hibernate imports. If you also want to take advantage of new features, using DAO helps you a lot: you know where to look at!

IMO, 1 DAO per POJO is too much, if you have a well packaged fined grained domain model, 1 DAO per package is good.
In my apps, generally only one package is necessary for a use case.

I mean, use-case *--1 package (in genaral, you can have reporting use-case that need pojo from many packages).
But this depends on the way you're designing your apps...


About architecture, i personaly use
JSP(view) 1--* Action(struts view controller) *--1 Business Delegate (delegation + business controller) *--* DAOInterface

I use DAO interface because some use case requires pure JDBC (because we just don't have money to rewrite them ;))

Stateless Session Beans are also ok.

I didn't want to add business control on the struts actions because it is clear to me that struts will be replaced (1 year maybe more) but that's only my POV.

Pojo are used on each layer of course.

For long application transaction i use a custom filter + hibernateUtils based on caveatemptor examples, i can switch between short and long session when i want.
For this, i'm using inheritance on business delegate (if businessDelegate is instance of longBusiness --> a long session is automatically with flushmode.NEVER and flush is called only at businessDelegate.commitApplicationTransaction(),... if not, we just use 1 session per http request and commit is called at the end of the filter).

Have in mind that application transaction don't have to be managed in the DAO layer, it's a business control problem.

Hope this helps.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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