3

When generating DTO objects, hibernate tools generate comments in the header:

// Generated 22 avr. 2013 20:29:27 by Hibernate Tools 3.4.0.CR1

Every generation the comments change (as they contains the generation date/time).

The problem is that in my SVN I end up having many non-usefull changes, so I have to check every single generated file to see whether to commit (if it contains actuals changes) or override it (if it's only the header).

Is there a way to avoid generating said header ?

Thank you.

Majid Laissi
  • 19,188
  • 19
  • 68
  • 105

1 Answers1

2

You would have to customize the Freemarker template which is found in hibernate-tools.jar. Navigate to the /pojo/Pojo.ftl and remove the line // Generated ${date} by Hibernate Tools ${version}.

Checking this out might help: https://forum.hibernate.org/viewtopic.php?f=6&t=989777&view=next

An example of a Hibernate tool Ant task (by specifying templatepath and hbmtemplate attributes:

<hibernatetool destdir="hibernate-model-gen/pojo" templatepath="hibernate-model-gen/customized-templates">
    <jdbcconfiguration configurationfile="hibernate-model-gen/hibernate.cfg.xml" packagename="open.pub.proto.core.model" revengfile="hibernate-model-gen\gen-conf\hibernate.reveng.xml" detectmanytomany="true" />
    <hbmtemplate templateprefix="pojo/" template="pojo/Pojo.ftl" filepattern="{package-name}/{class-name}.java">
        <property key="jdk5" value="true" />
        <property key="ejb3" value="true" />
    </hbmtemplate>
</hibernatetool>
Cy Pangilinan
  • 562
  • 1
  • 7
  • 22
  • you mean i'll need to recompile hibernate plugin ? there's no way i can set a parameter instead ? – Majid Laissi Apr 22 '13 at 21:49
  • I located the Pojo.ftl file, I'm going to set the template directory property in the `Hibernate Code Generation Configurations` editor to my template directory and will let you know. Thanks. – Majid Laissi Apr 22 '13 at 22:49