rfuentesp wrote:
I resolve the problem.
I put this:
<#assign lastIndexDot = p.type.returnedClass?last_index_of(".")>
${p.name}: ${p.type.returnedClass?substring(lastIndexDot + 1, p.type.returnedClass?length)}\l
And work :-)
sure, but it's a hack ;)
weird that the "real' method didn't work.
Quote:
By the way, I have a others freemarker files that work for the community.
For example:
In the PojoFields.ftl I add this:
<#foreach property in pojo.getAllPropertiesIterator()>
<#assign property_name_in_upper = "${property.name}"?upper_case>
public static final String ${property_name_in_upper} = "${property.name}";
</#foreach>
This create constants with the real names of the properties, very useful in the criteria queries, because the programer doesn't wrong type the name of the property.
there is a feature request in jira for this - but the way to generate this should be into an interface which users can then either say the entities implement or just refer to. Then i'll accept it into the codebase ;)
Quote:
Other is the generation of the toMap and fromMap methods:
toMap:
/**
* toMap
* @return Map
*/
public ${pojo.importType("java.util.Map")}<#if jdk5><String, Object></#if> toMap() {
Map<#if jdk5><String, Object></#if> map;
<#if pojo.isSubclass()>
map = super.toMap();
<#else>
map = new ${pojo.importType("java.util.HashMap")}<#if jdk5><String, Object></#if>();
</#if>
<#foreach property in pojo.getAllPropertiesIterator()>
<#assign property_name_in_upper = "${property.name}"?upper_case>
map.put(${property_name_in_upper}, ${pojo.getGetterSignature(property)}());
</#foreach>
return map;
}
fromMap:
/**
* fromMap
*/
public void fromMap(Map<#if jdk5><String, Object></#if> map) {
<#if pojo.isSubclass()>
super.fromMap(map);
</#if>
<#foreach property in pojo.getAllPropertiesIterator()>
<#assign property_name_in_upper = "${property.name}"?upper_case>
<#assign property_name_cap_first = "${property.name}"?cap_first>
set${pojo.getPropertyName(property)}((${pojo.getJavaTypeName(property, jdk5)}) map.get(${property_name_in_upper}));
</#foreach>
}
How I can contribute with this code?
about to/fromMap - isn't this better done with Hibernate's EntityMode.MAP ?