aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB questions. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB questions." Watch "EJB questions." New topic
Author

EJB questions.

Cristian Cardenas
Ranch Hand

Joined: Jan 29, 2002
Posts: 50
Hi,
First of all I'm going to describe the architecture I'm using.
I'm writting an application that uses an Oracle 9i Database, and Weblogic 6.1 sp1 as the Application Server. Also I use Entity CMP EJBs mapped to the database. In adittion I use Session EJBs as Facades of the Entity Beans. The presentation tier is implemented with JSP and Servlets (and perhaps XML).
1- When I have to return a "record set" to the client (in this case a JSP page) from the Facades I use a Collection containing Value Objects in place of a Collection containing Remote Interfaces to the Entity Beans. Is it a good solution in terms of performance?
2- It would be a good solution to return XML from the Facades in place of Collections?
3- Is there any API to generate XML from Collections?
Thanks in advance.
Cristian.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I suggest u not to create Entity bean retmote interface collection just for the purpose of displaying data.
I suggest u to retrive the data to be viewed from session beans using JDBC rather then calling findBy method of entity. The reason is u will end up creating ejbobjects for the entity beans ..and u are just displaying the data. U have un necessarialy created EJBobjects which are not used.Delay the creation of such objects until that entity is used.
I advice u not to use XML because of its nature of redunant data.
U can download Oracle XDK Kit from Oracle site that can convert database rows into XML file.


Groovy
Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi,
Returning Collections of remote interfaces wont be a good idea instead u can use value objects and keep all the records of the record set on the appserver and make calls to the app not to the db server.You can also use Updatable ResultSet using JDBC and keep all the records on the client side itsel and then retrieve it using javascript.
Using XML is necessiated only if your client is a hand held deveice, or a legacy application or anything other than a browser. You can use the JDOM model of the JAXP API for converting of your xml files into propreiatery ones and vice-versa.
Rishi
SCJP,SCWCD
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
I'm in agreement with everyone else. Returning a collection of Value Objects is by far the highest-performing solution of the set of solutions you've suggested.
I also believe that you should ONLY return XML if you plan on rendering your interface using XSLT -- and in that case, I'd probably STILL return value objects and then ask them to render themselves as XML inside the servlet.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
As Pradeep said, there can be problems with finders on entity beans. When you get a collection from a finder, the container will create entity objects in the pool for each of those objects. For finders that return many objects or heavily loaded servers this can be a problem (you can fill up the pool). If your finder only returns a few objects, it is not really a problem - only when the finder returns hundreds or thousands.
However, to trade the entity beans - and especially the advantages of CMP - for a session with pure JDBC is not really a good trade, IMHO.
You could replace the finder with a entity home method that uses a select method to return primary keys or value objects. This way the finder does not have to activate all of those beans, and you can still back the select method with EJB-QL.
As for the XML thing, where you do it depends on why you are doing it. If you are doing XML because of some needs in your presentation layer, then do the XML translation there. But if the XML is somehow fundamental to your middle-tier (either Model or Controler in MVC terms), then it would make sense to move it there.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Originally posted by Kyle Brown:
I'm in agreement with everyone else. Returning a collection of Value Objects is by far the highest-performing solution of the set of solutions you've suggested.
I also believe that you should ONLY return XML if you plan on rendering your interface using XSLT -- and in that case, I'd probably STILL return value objects and then ask them to render themselves as XML inside the servlet.
Kyle

Only thing I would change here is the "render themselves as XML inside the servlet." I am totally against having objects XMLize themselves. That should be done by an outside entity. Don't muddy up your business domain objects with XML code. Just my $0.02


James Carman, President<br />Carman Consulting, Inc.
 
wood burning stoves
 
subject: EJB questions.