This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

now without EJB

 
prasanna pati
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • 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 .
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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.
 
Chintan Rajyaguru
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • 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
 
No more fooling around. Read this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!