[
https://jira.jboss.org/jira/browse/JBSEAM-3260?page=com.atlassian.jira.pl...
]
Markus Neubrand updated JBSEAM-3260:
------------------------------------
Fix Version/s: (was: 2.0.3.CR2)
Used fix version accidentally
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
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