Yo guys,
I'm attempting to update an entity like so
manager.getTransaction().begin();
//attach entity to pers. context
//works fine
Obejct oldObj = doRead(newObj, manager);
//copy fields in newObj to oldObj
doMerge(oldObj,newObj);
//commit trans.
manager.getTransaction().commit();
here's the impl of doMerge, simple stuff...
private void mergeAdapter(IJPAAdapter src, Object dest)
{
Field[] destFields = dest.getClass().getDeclaredFields();
try
{
for (Field f : destFields)
{
if (!(f.isAnnotationPresent(Transient.class)))
{
f.setAccessible(true);
f.set(dest, f.get(src));
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
The fields get copied fine, however this changed entity never gets updated
in the data store.
however, if I create a copy method within my entity class which copies the
fields from the other object....this works fine.
I cannot figure out why the reflective solution wouldn't work but the second
would. Any thoughts?
thx a bunch
--
alessandro ferucci =]