1 Reply Latest reply on Feb 14, 2007 2:44 PM by Gavin King

    seam-gen code for many-to-one associations and reference dat

    Lawrie Gallardo Newbie


      I'm trying to understand the seam-generated code for many-to-one associations, and whether / how I need to modify it if I'm dealing with reference data that either is read-only (i.e. will be an Enum and will have matching database lookup table), or modified only very occasionally by an administrator (will be a class mapped to a database lookup/reference table).

      seam-gen generates the following Seam Application Framework EntityHome code for my example project's Customer class:

      public class CustomerHome extends EntityHome<Customer> {
       @In(value = "#{statusHome.managedInstance}", required = false)
       Status status;
       @In(value = "#{customerTypeHome.managedInstance}", required = false)
       CustomerType customerType;
       public void setCustomerId(Integer id) {
       public Integer getCustomerId() {
       return (Integer) getId();
       protected Customer createInstance() {
       Customer customer = new Customer();
       return customer;
       public void wire() {
       if (status != null) {
       if (customerType != null) {
       public boolean isWired() {
       if (getInstance().getStatus() == null)
       return false;
       if (getInstance().getCustomerType() == null)
       return false;
       return true;
       public Customer getManagedInstance() {
       return isManaged() ? getInstance() : null;

      and CustomerEdit.page.xml is generated as follows

      <page no-conversation-view-id="/CustomerList.xhtml">
       <begin-conversation join="true"/>
       <action execute="#{customerHome.wire}"/>
       <param name="customerFrom"/>
       <param name="customerId" value="#{customerHome.customerId}"/>
       <param name="statusFrom"/>
       <param name="statusId" value="#{statusHome.statusId}"/>
       <param name="customerTypeFrom"/>
       <param name="customerTypeId" value="#{customerTypeHome.customerTypeId}"/>
       <navigation from-action="#{customerHome.persist}">
       <redirect view-id="/Customer.xhtml"/>
       <navigation from-action="#{customerHome.update}">
       <redirect view-id="/Customer.xhtml"/>
       <navigation from-action="#{customerHome.remove}">
       <redirect view-id="/CustomerList.xhtml"/>

      So if I want Status to be an Enum, and CustomerType to be an immutable class that will be mapped to a database lookup/reference table, then what changes should I make to the seam-gen code???

      I particular, I'm confused by the need for the wire() and isWired() methods - can anyone shed any light on what they are for and whether I'll still need them?