I want to generate my entity and mapper files with MyBatis Generator. For a specific column, I wish when the field of the entity object has null value, the mapping file can treat it as a default value, like 0. I know how to configure this in the mapping file, i.e. 'defaultValue' . But I don't want to do this by hand every time I've generated the codes. Is there some way I can configure this setting in the mybatis generator config file so this setting can be generated automatically every time I run it?
Well, there is no way to handle it on a column name basis. You could handle it per type, using a type handler, or you have to write the dynamic sql each time.