For anyone looking here in the future, I ended up going with the answer @Igu suggested (#1) - which isn't necessarily for all attributes of all entities. (Unless I'm missing how it should be applied).
The macro looked like:
#macro( typeFor $attribute )
#if ( $attribute.neutralType == 'timestamp' )OffsetDateTime#else$attribute.simpleType#end
#end
Unfortunately, the formatting seems to be necessary in order to not add extra newlines or spaces in the generated .java
file. I added this macro definition to a common #parse
file and was able to use it across Models & DTOs alike.
Invoking the macro looks like this:
#foreach( $attribute in $entity.nonKeyAttributes )
$jpa.fieldAnnotations(2, $attribute)
private #typeFor( $attribute ) $attribute.name#if($attribute.hasInitialValue()) = ${attribute.initialValue}#end;
#end