This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Stateless DAO(EAO) versus POJO DAO Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Stateless DAO(EAO) versus POJO DAO" Watch "Stateless DAO(EAO) versus POJO DAO" New topic
Author

Stateless DAO(EAO) versus POJO DAO

Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
Is it better to use DAO as stateless or DAOs as POJO? What are the advantages and disadvantages?

thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26184
    
  66

Luciano,
It depends on what is in your DAO. Personally, I find it easier to write them as POJOs because I store state for the duration of the query. If your DAO is just a facade to something else (like a JPA entity), stateless is fine.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
Hi Jeanne,

Actually I do not store state, only delegate queries for the EntityManager. Here's an example of DAO that I am currently using:




But there came the idea of not using stateless, as example below:



The argument about this second way(just a POJO) is to improve performance.

Makes sense?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26184
    
  66

Originally posted by Luciano A. Pozzo:
The argument about this second way(just a POJO) is to improve performance.

Makes sense?

Kind of. It sounds like a case of premature optimization to me. If you have a problem with performance on that segment, sure. But I would think the database code would take many times longer than creating/injecting an object.
Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
thank you for your opinion Jeanne.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Stateless DAO(EAO) versus POJO DAO
 
Similar Threads
DAOs X POJOs X FACADEs
Session beans and Dao
Extended PersistenceContext on SFSB
JPA and DAO pattern
Business Delegate/Session Facade Question