I was trying to generate a Velocity template to have get/set methods
automatically generated for primary keys. I inserted code from the
non-PK area into the PK code but even after a couple of hours of trying
to follow the various hierarchies in the code, I was not able to get
what seemed like it ought to be a simple change to work properly. Here
is what I tried -- can someone give me the "cookbook" answer for how to
do this. (I know how to manually generate get/set methods using the
modeler.)
#if( $classGen.Entity.DbEntity )
#foreach( $idAttr in ${classGen.Entity.DbEntity.PrimaryKey} )
#set( $classGen.Prop = $idAttr.Name )## let controller know about
current property
public static final String ${classGen.propAsConstantName}_PK_COLUMN
= "${idAttr.Name}";
## Create PK set/get methods using code similar to that for non-PK
attributes. This is what does not work.
#if ("true" != "${classGen.getEntity().isReadOnly()}")
public void
set${classGen.cappedProp}($classGen.formatJavaType(${idAttr.Type})
$classGen.formatVariableName(${idAttr.Name})) {
writeProperty("${idAttr.Name}",
$classGen.formatVariableName(${idAttr.Name}));
}
#end
public $classGen.formatJavaType(${idAttr.Type})
get${classGen.cappedProp}() {
return
($classGen.formatJavaType(${idAttr.Type}))readProperty("${idAttr.Name}")
;
}
#end
#end
Best,
Joe
This archive was generated by hypermail 2.0.0 : Mon Jun 13 2005 - 14:28:22 EDT