I am trying to include following
private org.springframework.web.multipart.commons.CommonsMultipartFile photo;
@Transient
public CommonsMultipartFile getPhoto() {
return photo;
}
public void setPhoto(CommonsMultipartFile photo) {
this.photo = photo;
}
in my pojo class generated from database table.
I have studied to find there is a way to mention extra class code in meta tag like following
http://www.scribd.com/doc/23123635/30/Guiding-the-reverse-engineering-process
but this does not allow to add property variable photo.
Please suggest a way how can I do it in reveng.xml so that this code is included on every run of hbm2java.
Thanks in advance!
You can achieve such custom code by using reveng templates. If you open
hibernate-tools.jar
you will find .ftl files in thepojo
folder. You need to override them to put custom code.Steps:
If you are using maven then put this under
componentProperties
for hbm2java goal:Create
revenge.templates/pojo
folder under resources. Make sure that the folder name is alwayspojo
, otherwise the overrides are not detected.Create
pojo.ftl
file and copy the contents from thepojo.ftl
file present in the jar. Add all the import statements in this file.Similarly, follow the other files to find out where exactly you want to put the custom code.