On 3/23/05 5:35 PM, "Cris Daniluk" <cris.danilu..laraview.com> wrote:
> We frequently have a need to copy the properties of
> DataObjects back and forth (either to other DataObjects, or
> to beans further down the chain). BeanUtils is an obvious
> choice, but unfortunately it takes properties from
> CayenneDomainObject as well (specifically, the persistence
> state).
For encoding the DataObject properties for the XML encoding work I've been
doing, I have something like the following:
public void encodeAsXML(XMLEncoder encoder) {
EntityResolver er = getDataContext().getEntityResolver();
ObjEntity object = er.lookupObjEntity(getClass());
for (Iterator it = object.getDeclaredAttributes().iterator();
it.hasNext();) {
ObjAttribute att = (ObjAttribute) it.next();
String name = att.getName();
encoder.encodeProperty(name, readNestedProperty(name));
}
}
This is in CayenneDataObject, and it only retrieves declared attributes. I
had to do this for the exact same reason (encoding persistent state info in
XML doesn't make much sense). Anyway, this may be another way to satisfy
your needs.
-- Kevin
This archive was generated by hypermail 2.0.0 : Wed Mar 23 2005 - 21:57:58 EST