• 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

now without EJB

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my project I have used EJB ( CMP ) ,, now my manager wants to 'remove ' the EJB part for 1-2 module of the project OK ? now that means from java program I have to access a DAO and from a DAO I will access the database . is this approach ok ? I know core java and part of EJB which I have worked on . not much

so please help .
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you could rewire your exiting beans to use something like Hibernate. You will need to rethink session/transaction handling, though. In the EJB world it's common to leave that to the container - without one, that's the responsibilty of your code.
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This kind of problems require some analysis but here is an oversimplified answer:
Look at your EJB CMP layer and think about the things it's doing. In most cases, CMP EJBs,
1. Capture the domain model as EJBs
2. Define mappings to map EJBs to the database tables
3. Container takes care of executing transactions etc.

If you want to move away from CMP EJBs you will have to think of ways to do these things in your code. Here is what I would propose:
1. Create a layer of domain layer POJOs. If you had say AccountEJB, you will now have AccountVO. Note that you can still have primary key class etc. like you did before
2. Create a way to map VOs to database tables. This can be done by either creating a layer of DAOs and writing JDBC code in them OR by using a framework such as Toplink or Hibernate
3. Create a layer of stateless session beans (you probably have this already), which would either access DAO or invoke Hibernate to perform CRUD operations. Define transactions etc. on sessions beans

To specifically, answer your question, yes, you can use Java code - DAO - database as long as you take care of transactions etc.

Hope this helps, let me know if you have more questions...

Chintan
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic