Avoiding the complicated GET / SET operation is taken from: Xia Zhen hibernate_dev_guide To avoid the complicated Get / set operation, you can batch copy functionality provided by the Apache Jakarta Commons Beanutils component (http://jakarta.apache.org/commons/beanutils/ ). In the following example, we copy all properties of the User object to the AnotherUser object:
Tuser = new tuser ();
Tuser anotheruser = new tuser ();
User.setname ("EMMA");
User.setUsertype (1);
Try {
Beanutils.copyProperties (Anotheruser, User);
System.out.println ("UserName =>"
anotheruser.getname ()
);
System.out.println ("UserType =>"
AnotherUser.getusertype ()
);
} catch (IllegaCcessException E) {
E.PrintStackTrace ();
} catch (invocationTargeTexception E) {
E.PrintStackTrace ();
}
Tuser = new tuser ();
Tuser anotheruser = new tuser ();
User.setname ("EMMA");
User.setUsertype (1);
Try {
Beanutils.copyProperties (Anotheruser, User);
System.out.println ("UserName =>"
anotheruser.getname ()
);
System.out.println ("UserType =>"
AnotherUser.getusertype ()
);
} catch (IllegaCcessException E) {
E.PrintStackTrace ();
} catch (invocationTargeTexception E) {
E.PrintStackTrace ();
}
Tuser = new tuser ();
Tuser anotheruser = new tuser ();
User.setname ("EMMA");
User.setUsertype (1);
Try {
Beanutils.copyProperties (Anotheruser, User);
System.out.println ("UserName =>"
anotheruser.getname ()
);
System.out.println ("UserType =>"
AnotherUser.getusertype ()
);
} catch (IllegaCcessException E) {
E.PrintStackTrace ();
} catch (invocationTargeTexception E) {
E.PrintStackTrace ();
}