Reputation: 19
MyBatis generates the following code in one of my entity classes:
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column
* my_field
*
* @mbg.generated {DATETIME}
*/
@ParentToChildSync(sync = StringSync.class)
protected String myField;
I need to log the value of "myField". But as it is used widely in my project, the best place to log it would be in the setter I think. So I would like to write a custom setter to be able to add a log entry like so:
// ...
@ParentToChildSync(sync = StringSync.class)
protected String myField;
protected void setMyField(String myField) {
this.myField = myField;
log.add('set my field as: %s', myField);
}
Is this how I should do it? And if so how do I prevent MyBatis from overwriting/removing this customer setter next time I run the MyBatis generation?
Thank you!
Upvotes: 0
Views: 60