Issues with the ejbCreate for value objects:
1. ejbCreate for the value object is calling
setRelInstanceId instead of setRelInstance
2. ejbCreate should not be setting related instances,
ejbPostCreate should.
I created a macro that almost works for fixing #1 and
#2 can easily be fixed just by moving the set cmr stuff
from the ejbCreate to the ejbPostCreate.
How can you get the ejb CMR setter name for a value
objects CMP field?
#macro ( cmrValueSetters $table)
// Set CMR fields
#foreach($relationshipRole in
$table.mandatoryRelationshipRoles)
#set( $target = $relationshipRole.getTarget($plugin))
#if (!${relationshipRole.targetMany})
try
{
${target.localClassName} relInstance =
${target.utilClassName}.getLocalHome().findByPrimaryKey(value.${table.getVariableName($relationshipRole)});
$table.getSetterName($relationshipRole)(relInstance);
#set ( $throwsFinderExc = true )
} catch ( javax.naming.NamingException ne ) {
throw new
javax.ejb.CreateException(ne.getMessage());
#if ($throwsFinderExc)
} catch ( javax.ejb.FinderException fe ) {
throw new
javax.ejb.CreateException(fe.getMessage());
#end
}
#end
#end
#end