Thanks a lot.
For other's help, I also used an information here
https://forum.hibernate.org/viewtopic.php?f=6&t=959907&start=0, about how to name directories for hibernate tools to find the template files.
I'm using eclipse. Basically, using eclipse Team synch with an SVN plug-in, I added the SVN repository 'http://anonsvn.jboss.org/repos/hibernate/branches/Branch_3_2/HibernateExt/', browsed to
http://anonsvn.jboss.org/repos/hibernat ... lates/pojo, right-clicked and checked out into my existing project, in a subfolder I chose to name 'hibernate-templates', which thus contained a subfolder 'pojo' with the default templates.
Then I modified the following parts in PojoConstructors.ftl:
Code:
public ${pojo.getDeclarationName()}() {
/** Default generated constructor. */
}
I added a comment to avoid the compiler to complain that a block is empty.
Code:
<#foreach field in pojo.getPropertiesForMinimalConstructor()>
m_${field.name} = ${field.name};
</#foreach>
Code:
<#foreach field in pojo.getPropertiesForFullConstructor()>
m_${field.name} = ${field.name};
</#foreach>
My so loved m_ prefix (when init in the constructors).
In PojoEqualsHashcode.ftl:
Code:
<#if pojo.needsEqualsHashCode() && !clazz.superclass?exists> @Override
public boolean equals(Object other) {
//...
@Override
public int hashCode() {
To avoid compiler warning that Override annotation is missing.
In PojoFields.ftl:
Code:
</#if> ${pojo.getFieldModifiers(field)} ${pojo.getJavaTypeName(field, jdk5)} m_${field.name}<#if pojo.hasFieldInitializor(field, jdk5)> = ${pojo.getFieldInitialization(field, jdk5)}</#if>;
Prefix when declaring the fields.
And in PojoPropertyAccessors.ftl:
Code:
${pojo.getPropertyGetModifiers(property)} ${pojo.getJavaTypeName(property, jdk5)} ${pojo.getGetterSignature(property)}() {
return m_${property.name};
}
${pojo.getPropertySetModifiers(property)} void set${pojo.getPropertyName(property)}(${pojo.getJavaTypeName(property, jdk5)} ${property.name}) {
m_${property.name} = ${property.name};
}
Prefix when accessing the field.
I deleted the other ftl files from my project.
I think that the prefix thing should be optionally available using a configuration property in hibernate tools, because I think it is good practice to enable the compiler complaint when a local variable name overrides a field name, and the current default behavior of hibernate tools (requiring to modify the template, which is not such an easy thing at least for a beginner, IMHO) rather encourages the user to simply uncheck the compiler warning.
Even more advanced, the hibernate tools, when used as an eclipse plug-in, could use the fields prefix and suffix properties which can be set in Window / Preferences, Java / Code style.
Thanks again for your help.