My question revolves around remote interfaces and using the persistence API. An 
example might give more insight into my question?

I have 3 tables Customer, Order, LineItem with the corresponding object 
associations:


  | class Customer {
  | 
  |   long id;
  |   List<Order> orders;
  | 
  |   public long getId() {};
  |   public List<Order> getOrders(){};
  | }
  |  


  | class Order {
  | 
  |   long id;
  |   List<LineItem> lineItems;
  | 
  |   public long getId() {};
  |   public List<LineItem> getLineItems() {};
  |   public Customer getCustomer() {};
  | }
  | 

 
  | Class LineItem {
  | 
  |   long id;
  | 
  |   public long getId() {};
  |   public Order getOrder() {};
  | }
  | 
 

When using a session bean that implements a remote interface I make a call 
similar to the following?

  | @Stateless
  | class OrderBean implements RemoteOrder {
  | 
  |    public List<Order> getOrders(long custId) {
  |         return em.createNamedQuery(?order.findByCustomerId?)
  |                       .setParmater(?custId?, custId)
  |                       .getResultList();                      
  |    }
  | }
  | 

1)
Now this would work great in a Servlet/JSP that was running in the same JVM, 
but I am accessing this from a web service. I am wondering what is the 
?standard? way to return the persistent data to the web service client? Is it 
off load everything into value objects? Something has to be done otherwise I 
will always get exceptions when trying to access the lazy children of Customer. 
Even if I do a FETCH JOIN for Customer.orders then the problem nest down to 
Order.lineItems, should I FETCH JOIN this to? 

2)
What about the cyclic call during marhsalling from Customer.getOrders() then 
Orders.getCustomers()?  I have yet to find documentation ?anywhere? ;) that 
defines a standard way to handle this or should we still develop the J2EE way 
and use Transfer Objects (J2EE design Pattern), but I thought the persistence 
layer and POJOs was supposed to remove this extra layer from the enterprise 
application. 
 
3) 
If the Order Pojo had some header information an thats all I needed for a 
particluar web service request, meaning I do not want the lineitems, should I 
create another pojo object mapped to the table but with only the fields that 
represent the header? Should I create a Transfer Object/Value Object? 

I guess I am some confused of when or if I should use the Pojo when returning 
data for remote calls. I have read the J2EE Design Patterns and maybe those 
Patterns still apply I just thought that pojos where supposed to take place of 
value and transfer objects.

Thanks for any help :)
J

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962499#3962499

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962499
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to