jeudi 2 juillet 2015

java reflection MethodUtils

I have requirement to set the create date and created user (same for update).

In my entity manager custom code, I would like to access object tree

class Person {

private Contact personContact;
private Phone personPhone;
private List<Address> personAddressList;
}

And each class have same attributes like createDate, createUser, updateDate, updateUser

I want to recursivly check all object which are not null and set the create or update information.

I tried to do using

MethodUtils.invokeMethod(request, "setCreateTs", DateUtils.currentJavaTime());

This will set only the person object, how should I do for other object tree like contact or phone if they are not null.





Aucun commentaire:

Enregistrer un commentaire