aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB Model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB Model" Watch "EJB Model" New topic
Author

EJB Model

Patrick Ferguson
Ranch Hand

Joined: Jun 15, 2004
Posts: 30
Little background to this question first.

I'm a Java developer getting into EJB's, but not an EJB expert by any means. I recently started an EJB middleware project in which we had an EJB expert to layout the framework and get the ball rolling. Well he backed out last minute so they are looking to me to develop the EJB model.

Basically I have a transaction based system so it should be as simple as Client->Session Bean->Entity Bean->Database.

I need an example of how to use BMP Entities to access Stored Procedures, and also a simple diagram and snip of code to show how to grab the Entity Bean from the Session Bean would be great.

And if you know of any websites which show this I would be grateful. I've been to most of the standard newbie EJB sites, but can't get an answer to this.

Thanks.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Can you explain why you wish to:

1. Use entity beans.

2. Use BMP.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Patrick Ferguson
Ranch Hand

Joined: Jun 15, 2004
Posts: 30
Well the client wants to use EJB's due to other systems needing to remote in during later projects. We want to use stored procedures and from what I've read you have to then used BMP because CMP entity beans are 1-for-1 with a single table. Basically we want to use stateless session bean wrappers around the Entity beans.

This project doesn't really need EJB's, but it is what we were told to use.
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
In this case, I prefer not to use entity bean -- replace entity bean by Data Access Object (DAO)

Client->Session Bean->DAO ->Database.

DAO will encapsulate the call to store procedure and return Data Transfer Object (DAO) to session bean
Patrick Ferguson
Ranch Hand

Joined: Jun 15, 2004
Posts: 30
Please excuse my ignorance, but I was basically treating the Entity bean as the DAO. Can you be a bit more specific?
vu lee
Ranch Hand

Joined: Apr 19, 2005
Posts: 189
Patrick,
Since you have to use store procedures, I assume most of the persistence and transaction will be handled by the store procedures. I recommend to look up theDAO pattern which contains the implementation sammple code and the way to access DAO from SLSB. You'll need to call a proper store procedure in the method in the OracleXXXDAO class. E.g.

CallableStatement stproc_stmt = conn.prepareCall("{ ? = call _funcname(?,?,?)}");
Patrick Ferguson
Ranch Hand

Joined: Jun 15, 2004
Posts: 30
Thank you for that link it is very informative. After doing more reading I came across this site which explains the top level of what I was looking for. http://www.urbancode.com/projects/ejbbenchmark/idioms.jsp#SE

What you are describing is the Coarse Grained Session Bean Idiom at the bottom of that page which I actually suggested at the beginning of the project(not knowing it actually had a name, I just didn't know why we needed Entity beans since we were using stored procedures). But the then EJB "Expert" said we had to have Entity beans.

Thank you for your information.
 
 
subject: EJB Model