S
sameergn
Hi,
We are using a Java bean, say User.java, which represents a database
table, say user. User.java has a method setName(), which may do some
(simple or complex) validations, which must be carried out when
application code calls setName() method.
The same validation code will be executed by hibernate when loading
User object from database and calling setName() on it. The validation
code need not be executed here as data is getting loaded from
database.
Is there any solution/pattern/recommendation to avoid this performance
penalty?
Our current solution is to name instance variable as _name and then
providing a (private) set_name() method for hibernate while will not
carry out any validations. Then provide one more method setName()
which will set same _name instance variable but after doing whole lot
of validations. This method must be used by application code and will
be made public.
This approach requires duplicating all getters and setters. Any
comments?
Thanks,
Sameer
We are using a Java bean, say User.java, which represents a database
table, say user. User.java has a method setName(), which may do some
(simple or complex) validations, which must be carried out when
application code calls setName() method.
The same validation code will be executed by hibernate when loading
User object from database and calling setName() on it. The validation
code need not be executed here as data is getting loaded from
database.
Is there any solution/pattern/recommendation to avoid this performance
penalty?
Our current solution is to name instance variable as _name and then
providing a (private) set_name() method for hibernate while will not
carry out any validations. Then provide one more method setName()
which will set same _name instance variable but after doing whole lot
of validations. This method must be used by application code and will
be made public.
This approach requires duplicating all getters and setters. Any
comments?
Thanks,
Sameer