[jboss-user] [JBoss Seam] - Re: Need some clarification about seam-gen-ed EntityHome cla

gavin.king@jboss.com do-not-reply at jboss.com
Thu May 24 10:26:37 EDT 2007


Depends upon whether the attribute is optional or not. If the FK column is nullable, an entity can be saved without a value for the FK.

You can see all this stuff by looking at the template:

    public void wire()
  |     {
  | <#foreach property in pojo.allPropertiesIterator>
  | <#if c2h.isManyToOne(property)>
  | <#assign parentPojo = c2j.getPOJOClass(cfg.getClassMapping(property.value.referencedEntityName))>
  | <#if parentPojo.shortName!=pojo.shortName>
  | <#assign parentHomeName = util.lower(parentPojo.shortName) + "Home">
  | <#assign setter = "set" + pojo.getPropertyName(property)>
  |         ${parentPojo.shortName} ${property.name}=${parentHomeName}.getDefinedInstance();
  |         if ( ${property.name}!=null )
  |         {
  |            getInstance().${setter}(${property.name});
  |         }
  | </#if>
  | </#if>
  | </#foreach>
  |     }
  |     
  |     public boolean isWired()
  |     {
  | <#foreach property in pojo.allPropertiesIterator>
  | <#if (c2h.isManyToOne(property) && !property.optional)>
  | <#assign getter = pojo.getGetterSignature(property)>
  |         if ( getInstance().${getter}()==null ) return false;
  | </#if>
  | </#foreach>
  |         return true;
  |     }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048326#4048326

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048326



More information about the jboss-user mailing list