From: Dain S. <da...@da...> - 2002-11-04 23:10:48
|
Luttrell, Peter wrote: > Bill also suggested that it was my code, which i don't think is the case. I > could be wrong ~ can anyone suggest how i can optimize this constructor: > > public MyValueObject(SomeLocalInterface ejb){ > > name = ejb.getName(); > id = ejb.getId(); > someOtherField = ejb.getSomeOtherField(); > } > > There are about 10 fields or so. I did double check and realize that one of > them is a field on a relationship, which may be the source of the problem. You are doing 10 invocations through the ejb layers. The code will be way more efficient if you put the value object creation code inside the entity bean. For example public abstract class MyEntityBean extends EJBObject { public MyValueObject getValueObject() { MyValueObject valueObject = new MyValueObject(); valueObject.setName(getName()); valueObject.setId(getId()); valueObject.setSomeOtherField(getSomeOtherField()); } } The important difference is the loading of the value object gets all of the data from the ejb using calls inside of the bean instance and specifically the calls don't travel over a Remote or Local interface. This means there is no code interpositioned. -dain |