I am new to entity beans and have been working to figure out the proper method to use
entity beans in a web based application. Currently I have created a Stateless Session
Bean to work with the Local Entity beans. I am noticing performance issues when using
relationships between two Entity Beans. For example if I call customer.getOrders()
which returns a collection of all related Order entity beans and try to iterator of
them it seems to appear much slower than by using straight JDBC. Below is some sample
code from the Session Bean. Thanks for any help to set me on the right path.
| public java.util.Collection getOrders(int clientId)
| ClientException
| {
| ArrayList orderList = new ArrayList();
| try
| {
| Context ctx = new InitialContext();
| Object obj = ctx.lookup(ClientLocalHome.JNDI_NAME);
|
| // Get the home interface
| ClientLocalHome home =
| (ClientLocalHome)PortableRemoteObject.narrow(obj,
ClientLocalHome.class);
|
| // Get the stub
| ClientLocal client =
| home.findByPrimaryKey(new ClientPK(new Integer(clientId)));
|
| // Get the Collection of orders
| Iterator iter = client.getOrders().iterator();
| while(iter.hasNext())
| {
| Order order = new Order();
| OrdersLocal local = (OrdersLocal)iter.next();
| order.setOrderId(local.getOrderId().intValue());
| order.setOrderDate(local.getOrderDate());
| order.setClient(client.getName());
| order.setTotalRevenue(local.getTotalRevenue()
| .doubleValue());
| // Add the orderDO to the list
| orderList.add(order);
| }
|
|
| }
| catch(Exception e)
| {
| throw new ClientException("Unable to retreive orders. Cause: "
| + e.getMessage());
| }
|
| // Return the collection of orders
| return(orderList);
| }
|
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3853550#3853550
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3853550
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user