• 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

DAO vs. Entity Beans

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which case we will prefer entity beans and in which case we prefer DAO?
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
We can not compare a Pattern (DAO) with a persistence technology Entity beans.
we can use a DAO pattern over entity beans , plain JDBC , hibernate , JDO , ...
So you use DAO to encapsulate Data Access in a seperate layer and make data access independent of persistence technology and abstract the access to data from upper layers.
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Hemant Agarwal:
In which case we will prefer entity beans and in which case we prefer DAO?



The purpose of DAO pattern is to uncouple the database logic from other work flow. Entity beans are used for persistance. So both are different purposes.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
..but you can use DAOs for persistence. After all, they are Data Access Objects. There's no reason say they can't be used for persistence. At my comapany, we have two types of DAOs: entity DAOs and custom DAOs. The entity DAOs handle persistence (and are generated based on the database, so we don't have to hand code them), the custom ones handle whatever they need to.

Personally, I stopped using entity beans years ago -- back around EJB v1.1. They were (and still are) cumbersome and don't translate between application servers very well. My company changed from entity EJBs to straight DAO because the Entity Bean model just didn't work very well (performance was also an issue).

So, my recommendation is quite simple: don't use entity beans. There are a number of other persistence mechanisms out there that cause fewer headaches (Hibernate, strainght DAO, etc.)
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joel McNary:
..but you can use DAOs for persistence. After all, they are Data Access Objects. There's no reason say they can't be used for persistence.



I did not mean we can not use DAOs for persistence. I mean to say that the purpose of DAOs are to uncouple the database logic so that any changes in database related activities(like change in database) will become simpler.

From Sun Blueprints:
Use a Data Access Object (DAO) to abstract and encapsulate all access to the data source. The DAO manages the connection with the data source to obtain and store data.
 
Masoud Kalali
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Personally, I stopped using entity beans years ago -- back around EJB v1.1. They were (and still are) cumbersome and don't translate between application servers very well. [/QB]



Maybe you should take a look at EJB 3 Spec and JPA ;-)
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun Blue prints suggests that use DAOs from Entity Bean when you need to implmenta database related operations inside Entity Bean.
 
reply
    Bookmark Topic Watch Topic
  • New Topic