• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Stateless DAO(EAO) versus POJO DAO

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it better to use DAO as stateless or DAOs as POJO? What are the advantages and disadvantages?

thanks
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your opinion Jeanne.
reply
    Bookmark Topic Watch Topic
  • New Topic