[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-3260) Seam-gen generates @In for referenced EntityHomes twice in some cases
Markus Neubrand (JIRA)
jira-events at lists.jboss.org
Wed Aug 13 14:28:40 EDT 2008
Seam-gen generates @In for referenced EntityHomes twice in some cases
---------------------------------------------------------------------
Key: JBSEAM-3260
URL: https://jira.jboss.org/jira/browse/JBSEAM-3260
Project: Seam
Issue Type: Patch
Components: Tools
Affects Versions: 2.0.2.SP1
Reporter: Markus Neubrand
Fix For: 2.0.3.CR2
If an reverse engineered entity has two ManyToOne relations to the same entity the following code
in <seam-home>/seam-gen/src/EntityHome.java.ftl generates the @In for the referenced EntityHome twice:
<#foreach property in pojo.allPropertiesIterator>
<#if c2h.isManyToOne(property)>
<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
<#assign parentHomeName = util.lower(parentPojo.shortName) + "Home">
@${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
${parentPojo.shortName}Home ${parentHomeName};
</#if>
</#foreach>
To fix this issue the template must implement a check to determine if the @In was already generated for the given
parentPojo.shortName. I'm not very familiar with Freemarker so i think the patch below is a very ugly solution but
at least it works for me:
<#assign usedParentPojo = "">
<#foreach property in pojo.allPropertiesIterator>
<#if c2h.isManyToOne(property)>
<#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
<#if !usedParentPojo?contains("@" + parentPojo.shortName + "@")>
<#assign parentHomeName = util.lower(parentPojo.shortName) + "Home">
@${pojo.importType("org.jboss.seam.annotations.In")}(create=true)
${parentPojo.shortName}Home ${parentHomeName};
</#if>
<#assign usedParentPojo = usedParentPojo + "@" + parentPojo.shortName + "@">
</#if>
</#foreach>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list