• 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 OR EJB

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello there ,

i want to know when i have to use DAO With POJO or use EJB and if anybody know please can he give exmaple and resource about this issue

Tariq Shadid

JAVA DEVELOPER
 
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
Tariq,
In general, you use EJB if you need services the container provides like security or transaction support. You can use session beans to wrap POJOs or entity beans for this benefit.

Note that in EJB 3.0, EJBs are annotated POJOs that provide these services.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition to whatever Jaene has pointed out, the main advantage of using EJBs is scalability. Even when you use EJBs, you will still use DAOs to talk to database. You may also use some other POJO objects as services between the EJBs and your DAOs. These services can handle your business logic. This gives a good level of abstraction. Thus if you decide to run your services outside the EJB container you can just take your POJO services and deploy them in a web container if you have your own custom framework to take care of whatever an EJB container provides. Bottomline is, if you are looking for a scalable architecture go for EJB. But remember anything good comes with a price...
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use DAO when you want a persistence layer without EJBs. You write all the Java/JDBC/SQL code.

Use entity bean when you need EJBs, which means your app is distributed, transactional, high availability, high throughput, clustered, etc.
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like just to add that in my case I'm using DAOs for getting read-only data as they are about twice time faster than entity beans, espacially when i need to read data from 2-3 beans.
 
reply
    Bookmark Topic Watch Topic
  • New Topic