/*
 * IMPORTANT!!!! XSL Autogenerated class, DO NOT EDIT!!!!!
 * Template: Infrastructure8.2 rev3 [oneit.objstore.BusinessObjectTemplate.xsl]
 *
 *   Version: 1.0
 *   Vendor: Apache Software Foundation (Xalan XSLTC)
 *   Vendor URL: http://xml.apache.org/xalan-j
 */


    package performa.orm;

import java.io.*;
import java.util.*;
import oneit.appservices.config.*;
import oneit.logging.*;
import oneit.objstore.*;
import oneit.objstore.assocs.*;
import oneit.objstore.attributes.*;
import oneit.objstore.rdbms.filters.*;
import oneit.objstore.parser.*;
import oneit.objstore.validator.*;
import oneit.objstore.utils.*;
import oneit.utils.*;
import oneit.utils.filter.Filter;
import oneit.utils.transform.*;
import oneit.utils.parsers.FieldException;

import performa.orm.types.*;



public abstract class BaseOccupation extends BaseBusinessClass
{
    // Reference instance for the object
    public static final Occupation REFERENCE_Occupation = new Occupation ();

    // Reference instance for the object
    public static final Occupation DUMMY_Occupation = new DummyOccupation ();

    // Static constants corresponding to field names
    
    public static final String FIELD_Code = "Code";
    public static final String FIELD_Name = "Name";
    public static final String FIELD_Level = "Level";
    public static final String FIELD_AssessmentType = "AssessmentType";
    public static final String FIELD_PartTimeAssessmentType = "PartTimeAssessmentType";
    public static final String SINGLEREFERENCE_AssessmentLevel = "AssessmentLevel";
    public static final String SINGLEREFERENCE_ExpressAssessmentLevel = "ExpressAssessmentLevel";
    public static final String SINGLEREFERENCE_ParentOccupation = "ParentOccupation";
    public static final String BACKREF_ParentOccupation = "";
    public static final String MULTIPLEREFERENCE_ChildOccupations = "ChildOccupations";
    public static final String BACKREF_ChildOccupations = "";

    // Static constants corresponding to searches
    public static final String SEARCH_All = "All";
    

    // Static constants corresponding to attribute helpers
    private static final DefaultAttributeHelper<Occupation> HELPER_Code = DefaultAttributeHelper.INSTANCE;
    private static final DefaultAttributeHelper<Occupation> HELPER_Name = DefaultAttributeHelper.INSTANCE;
    private static final EnumeratedAttributeHelper<Occupation, OccupationLevel> HELPER_Level =  new EnumeratedAttributeHelper<Occupation, OccupationLevel> (OccupationLevel.FACTORY_OccupationLevel);
    private static final EnumeratedAttributeHelper<Occupation, AssessmentType> HELPER_AssessmentType =  new EnumeratedAttributeHelper<Occupation, AssessmentType> (AssessmentType.FACTORY_AssessmentType);
    private static final EnumeratedAttributeHelper<Occupation, AssessmentType> HELPER_PartTimeAssessmentType =  new EnumeratedAttributeHelper<Occupation, AssessmentType> (AssessmentType.FACTORY_AssessmentType);
    

    // Private attributes corresponding to business object data
    private String _Code;
    private String _Name;
    private OccupationLevel _Level;
    private AssessmentType _AssessmentType;
    private AssessmentType _PartTimeAssessmentType;
    

    // Private attributes corresponding to single references
    private SingleAssociation<Occupation, Level> _AssessmentLevel;
    private SingleAssociation<Occupation, Level> _ExpressAssessmentLevel;
    private SingleAssociation<Occupation, Occupation> _ParentOccupation;
    

    // Private attributes corresponding to multiple references
    private MultipleAssociation<Occupation, Occupation> _ChildOccupations;
    

    // Map of maps of metadata
    private static final Map ATTRIBUTES_METADATA_Occupation = new HashMap ();

    // Arrays of validators for each attribute
    private static final AttributeValidator[] FIELD_Code_Validators;
    private static final AttributeValidator[] FIELD_Name_Validators;
    private static final AttributeValidator[] FIELD_Level_Validators;
    private static final AttributeValidator[] FIELD_AssessmentType_Validators;
    private static final AttributeValidator[] FIELD_PartTimeAssessmentType_Validators;
    

    // Arrays of behaviour decorators
    private static final OccupationBehaviourDecorator[] Occupation_BehaviourDecorators;
    
    static
    {
        try
        {
            
            String tmp_ChildOccupations = Occupation.BACKREF_ParentOccupation;
            String tmp_ParentOccupation = Occupation.BACKREF_ChildOccupations;
            
            Map  validatorMapping = ((Map)ConfigMgr.getConfigObject ("CONFIG.ORMVALIDATOR", "ValidatorMapping"));

            setupAssocMetaData_ChildOccupations();
            setupAssocMetaData_AssessmentLevel();
            setupAssocMetaData_ExpressAssessmentLevel();
            setupAssocMetaData_ParentOccupation();
            FIELD_Code_Validators = (AttributeValidator[])setupAttribMetaData_Code(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Name_Validators = (AttributeValidator[])setupAttribMetaData_Name(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_Level_Validators = (AttributeValidator[])setupAttribMetaData_Level(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_AssessmentType_Validators = (AttributeValidator[])setupAttribMetaData_AssessmentType(validatorMapping).toArray (new AttributeValidator[0]);
            FIELD_PartTimeAssessmentType_Validators = (AttributeValidator[])setupAttribMetaData_PartTimeAssessmentType(validatorMapping).toArray (new AttributeValidator[0]);
            

            REFERENCE_Occupation.initialiseReference ();
            DUMMY_Occupation.initialiseReference ();
            Occupation_BehaviourDecorators = BaseBusinessClass.getBBCBehaviours(Occupation.class).toArray(new OccupationBehaviourDecorator[0]);
        }
        catch (RuntimeException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR1, e, "Error initialising");
            throw e;
        }
    }

    
    // Meta Info setup
    private static void setupAssocMetaData_ChildOccupations()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "ParentOccupation");
        metaInfo.put ("name", "ChildOccupations");
        metaInfo.put ("type", "Occupation");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.ChildOccupations:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (MULTIPLEREFERENCE_ChildOccupations, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_AssessmentLevel()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "assessment_level_id");
        metaInfo.put ("name", "AssessmentLevel");
        metaInfo.put ("type", "Level");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.AssessmentLevel:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (SINGLEREFERENCE_AssessmentLevel, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_ExpressAssessmentLevel()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("dbcol", "express_assessment_level_id");
        metaInfo.put ("name", "ExpressAssessmentLevel");
        metaInfo.put ("type", "Level");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.ExpressAssessmentLevel:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (SINGLEREFERENCE_ExpressAssessmentLevel, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static void setupAssocMetaData_ParentOccupation()
    {
        Map metaInfo = new HashMap ();

        metaInfo.put ("backreferenceName", "ChildOccupations");
        metaInfo.put ("dbcol", "parent_occupation_id");
        metaInfo.put ("name", "ParentOccupation");
        metaInfo.put ("type", "Occupation");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.ParentOccupation:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (SINGLEREFERENCE_ParentOccupation, Collections.unmodifiableMap (metaInfo));
    }
    
    
    // Meta Info setup
    private static List setupAttribMetaData_Code(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "code");
        metaInfo.put ("isUnique", "true");
        metaInfo.put ("length", "4");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Code");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.Code:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (FIELD_Code, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Occupation.class, "Code", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Occupation.Code:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_Name(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("dbcol", "name");
        metaInfo.put ("length", "250");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Name");
        metaInfo.put ("type", "String");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.Name:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (FIELD_Name, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Occupation.class, "Name", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Occupation.Name:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_Level(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "level");
        metaInfo.put ("mandatory", "true");
        metaInfo.put ("name", "Level");
        metaInfo.put ("type", "OccupationLevel");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.Level:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (FIELD_Level, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Occupation.class, "Level", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Occupation.Level:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_AssessmentType(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "assessment_type");
        metaInfo.put ("name", "AssessmentType");
        metaInfo.put ("type", "AssessmentType");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.AssessmentType:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (FIELD_AssessmentType, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Occupation.class, "AssessmentType", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Occupation.AssessmentType:", validators);        

        return validators;
    }
    
    // Meta Info setup
    private static List setupAttribMetaData_PartTimeAssessmentType(Map validatorMapping)
    {
        Map  metaInfo   = new HashMap ();

        metaInfo.put ("attribHelper", "EnumeratedAttributeHelper");
        metaInfo.put ("dbcol", "parttime_assessment_type");
        metaInfo.put ("name", "PartTimeAssessmentType");
        metaInfo.put ("type", "AssessmentType");
        
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG2, "Metadata for Occupation.PartTimeAssessmentType:", metaInfo);
        ATTRIBUTES_METADATA_Occupation.put (FIELD_PartTimeAssessmentType, Collections.unmodifiableMap (metaInfo));

        List validators = BaseBusinessClass.getAttribValidators(Occupation.class, "PartTimeAssessmentType", metaInfo, validatorMapping);
        LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Validators for Occupation.PartTimeAssessmentType:", validators);        

        return validators;
    }
    
    // END OF STATIC METADATA DEFINITION    
    
    
    
    // This constructor should not be called
    protected BaseOccupation ()
    {
    }


    protected BBCBehaviourDecorator[] getBehaviours()
    {
        return Occupation_BehaviourDecorators;
    }
    
    


    


    // Initialise the attributes
    protected void _initialiseNewObjAttributes (ObjectTransaction transaction) throws StorageException
    {
        super._initialiseNewObjAttributes (transaction);

        
        _Code = (String)(HELPER_Code.initialise (_Code));
        _Name = (String)(HELPER_Name.initialise (_Name));
        _Level = (OccupationLevel)(HELPER_Level.initialise (_Level));
        _AssessmentType = (AssessmentType)(HELPER_AssessmentType.initialise (_AssessmentType));
        _PartTimeAssessmentType = (AssessmentType)(HELPER_PartTimeAssessmentType.initialise (_PartTimeAssessmentType));
    }


    // Initialise the associations
    protected void _initialiseAssociations ()
    {
        super._initialiseAssociations ();

        _AssessmentLevel = new SingleAssociation<Occupation, Level> (this, SINGLEREFERENCE_AssessmentLevel, null, Level.REFERENCE_Level, "tl_occupation");
        _ExpressAssessmentLevel = new SingleAssociation<Occupation, Level> (this, SINGLEREFERENCE_ExpressAssessmentLevel, null, Level.REFERENCE_Level, "tl_occupation");
        _ParentOccupation = new SingleAssociation<Occupation, Occupation> (this, SINGLEREFERENCE_ParentOccupation, Occupation.MULTIPLEREFERENCE_ChildOccupations, Occupation.REFERENCE_Occupation, "tl_occupation");
        _ChildOccupations = new MultipleAssociation<Occupation, Occupation> (this, MULTIPLEREFERENCE_ChildOccupations, Occupation.SINGLEREFERENCE_ParentOccupation, Occupation.REFERENCE_Occupation);
        
    }


    // Initialise the associations
    protected BaseBusinessClass initialiseReference ()
    {
        super.initialiseReference ();
        
        _AssessmentLevel = new SingleAssociation<Occupation, Level> (this, SINGLEREFERENCE_AssessmentLevel, null, Level.REFERENCE_Level, "tl_occupation");
        _ExpressAssessmentLevel = new SingleAssociation<Occupation, Level> (this, SINGLEREFERENCE_ExpressAssessmentLevel, null, Level.REFERENCE_Level, "tl_occupation");
        _ParentOccupation = new SingleAssociation<Occupation, Occupation> (this, SINGLEREFERENCE_ParentOccupation, Occupation.MULTIPLEREFERENCE_ChildOccupations, Occupation.REFERENCE_Occupation, "tl_occupation");
        _ChildOccupations = new MultipleAssociation<Occupation, Occupation> (this, MULTIPLEREFERENCE_ChildOccupations, Occupation.SINGLEREFERENCE_ParentOccupation, Occupation.REFERENCE_Occupation);
        
        
        return this;
    }

    

    /**
     * Get the attribute Code
     */
    public String getCode ()
    {
        assertValid();
        String valToReturn = _Code;

            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                valToReturn = bhd.getCode ((Occupation)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preCodeChange (String newCode) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postCodeChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_Code ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute Code.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setCode (String newCode) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Code.compare (_Code, newCode);
        
        try
        {
            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                newCode = bhd.setCode ((Occupation)this, newCode);
                oldAndNewIdentical = HELPER_Code.compare (_Code, newCode);
            }

            BusinessObjectParser.assertFieldCondition (newCode != null, this, FIELD_Code, "mandatory");
            

            if (FIELD_Code_Validators.length > 0)
            {
                Object newCodeObj = HELPER_Code.toObject (newCode);

                if (newCodeObj != null)
                {
                    int     loopMax = FIELD_Code_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Occupation.get (FIELD_Code);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_Code_Validators[v].checkAttribute (this, FIELD_Code, metadata, newCodeObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Code () != FieldWriteability.FALSE, "Field  Code is not writeable");
            preCodeChange (newCode);
            markFieldChange (FIELD_Code);
            _Code = newCode;            
            postFieldChange (FIELD_Code);
            postCodeChange ();
        }
    }

    /**
     * Get the attribute Name
     */
    public String getName ()
    {
        assertValid();
        String valToReturn = _Name;

            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                valToReturn = bhd.getName ((Occupation)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preNameChange (String newName) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postNameChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_Name ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute Name.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setName (String newName) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Name.compare (_Name, newName);
        
        try
        {
            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                newName = bhd.setName ((Occupation)this, newName);
                oldAndNewIdentical = HELPER_Name.compare (_Name, newName);
            }

            BusinessObjectParser.assertFieldCondition (newName != null, this, FIELD_Name, "mandatory");
            

            if (FIELD_Name_Validators.length > 0)
            {
                Object newNameObj = HELPER_Name.toObject (newName);

                if (newNameObj != null)
                {
                    int     loopMax = FIELD_Name_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Occupation.get (FIELD_Name);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_Name_Validators[v].checkAttribute (this, FIELD_Name, metadata, newNameObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Name () != FieldWriteability.FALSE, "Field  Name is not writeable");
            preNameChange (newName);
            markFieldChange (FIELD_Name);
            _Name = newName;            
            postFieldChange (FIELD_Name);
            postNameChange ();
        }
    }

    /**
     * Get the attribute Level
     */
    public OccupationLevel getLevel ()
    {
        assertValid();
        OccupationLevel valToReturn = _Level;

            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                valToReturn = bhd.getLevel ((Occupation)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preLevelChange (OccupationLevel newLevel) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postLevelChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_Level ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute Level.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setLevel (OccupationLevel newLevel) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_Level.compare (_Level, newLevel);
        
        try
        {
            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                newLevel = bhd.setLevel ((Occupation)this, newLevel);
                oldAndNewIdentical = HELPER_Level.compare (_Level, newLevel);
            }

            BusinessObjectParser.assertFieldCondition (newLevel != null, this, FIELD_Level, "mandatory");
            

            if (FIELD_Level_Validators.length > 0)
            {
                Object newLevelObj = HELPER_Level.toObject (newLevel);

                if (newLevelObj != null)
                {
                    int     loopMax = FIELD_Level_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Occupation.get (FIELD_Level);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_Level_Validators[v].checkAttribute (this, FIELD_Level, metadata, newLevelObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_Level () != FieldWriteability.FALSE, "Field  Level is not writeable");
            preLevelChange (newLevel);
            markFieldChange (FIELD_Level);
            _Level = newLevel;            
            postFieldChange (FIELD_Level);
            postLevelChange ();
        }
    }

    /**
     * Get the attribute AssessmentType
     */
    public AssessmentType getAssessmentType ()
    {
        assertValid();
        AssessmentType valToReturn = _AssessmentType;

            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                valToReturn = bhd.getAssessmentType ((Occupation)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preAssessmentTypeChange (AssessmentType newAssessmentType) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postAssessmentTypeChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_AssessmentType ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute AssessmentType.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setAssessmentType (AssessmentType newAssessmentType) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_AssessmentType.compare (_AssessmentType, newAssessmentType);
        
        try
        {
            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                newAssessmentType = bhd.setAssessmentType ((Occupation)this, newAssessmentType);
                oldAndNewIdentical = HELPER_AssessmentType.compare (_AssessmentType, newAssessmentType);
            }

            

            if (FIELD_AssessmentType_Validators.length > 0)
            {
                Object newAssessmentTypeObj = HELPER_AssessmentType.toObject (newAssessmentType);

                if (newAssessmentTypeObj != null)
                {
                    int     loopMax = FIELD_AssessmentType_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Occupation.get (FIELD_AssessmentType);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_AssessmentType_Validators[v].checkAttribute (this, FIELD_AssessmentType, metadata, newAssessmentTypeObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_AssessmentType () != FieldWriteability.FALSE, "Field  AssessmentType is not writeable");
            preAssessmentTypeChange (newAssessmentType);
            markFieldChange (FIELD_AssessmentType);
            _AssessmentType = newAssessmentType;            
            postFieldChange (FIELD_AssessmentType);
            postAssessmentTypeChange ();
        }
    }

    /**
     * Get the attribute PartTimeAssessmentType
     */
    public AssessmentType getPartTimeAssessmentType ()
    {
        assertValid();
        AssessmentType valToReturn = _PartTimeAssessmentType;

            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                valToReturn = bhd.getPartTimeAssessmentType ((Occupation)this, valToReturn);
            }
            
            return valToReturn;
        
    }


    /**
     * Called prior to the attribute changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void prePartTimeAssessmentTypeChange (AssessmentType newPartTimeAssessmentType) throws FieldException
    {
    }


    /**
     * Called after the attribute changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postPartTimeAssessmentTypeChange () throws FieldException
    {
    }

    
    public FieldWriteability getWriteability_PartTimeAssessmentType ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }

    /**
     * Set the attribute PartTimeAssessmentType.  Checks to ensure a new value
     * has been supplied.  If so, marks the field as altered and sets the attribute.
     */
    public void setPartTimeAssessmentType (AssessmentType newPartTimeAssessmentType) throws FieldException
    {
        boolean oldAndNewIdentical = HELPER_PartTimeAssessmentType.compare (_PartTimeAssessmentType, newPartTimeAssessmentType);
        
        try
        {
            for (OccupationBehaviourDecorator bhd : Occupation_BehaviourDecorators)
            {
                newPartTimeAssessmentType = bhd.setPartTimeAssessmentType ((Occupation)this, newPartTimeAssessmentType);
                oldAndNewIdentical = HELPER_PartTimeAssessmentType.compare (_PartTimeAssessmentType, newPartTimeAssessmentType);
            }

            

            if (FIELD_PartTimeAssessmentType_Validators.length > 0)
            {
                Object newPartTimeAssessmentTypeObj = HELPER_PartTimeAssessmentType.toObject (newPartTimeAssessmentType);

                if (newPartTimeAssessmentTypeObj != null)
                {
                    int     loopMax = FIELD_PartTimeAssessmentType_Validators.length;
                    Map     metadata = (Map)ATTRIBUTES_METADATA_Occupation.get (FIELD_PartTimeAssessmentType);

                    for (int v = 0 ; v < loopMax ; ++v)
                    {
                        FIELD_PartTimeAssessmentType_Validators[v].checkAttribute (this, FIELD_PartTimeAssessmentType, metadata, newPartTimeAssessmentTypeObj);
                    }
                }
            }
        }
        catch (FieldException e)
        {
            if (!oldAndNewIdentical)
            {
                e.setWouldModify ();
            }
            
            throw e;
        }

        if (!oldAndNewIdentical)
        {
            assertValid();
            Debug.assertion (getWriteability_PartTimeAssessmentType () != FieldWriteability.FALSE, "Field  PartTimeAssessmentType is not writeable");
            prePartTimeAssessmentTypeChange (newPartTimeAssessmentType);
            markFieldChange (FIELD_PartTimeAssessmentType);
            _PartTimeAssessmentType = newPartTimeAssessmentType;            
            postFieldChange (FIELD_PartTimeAssessmentType);
            postPartTimeAssessmentTypeChange ();
        }
    }



    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getSingleAssocs()
    {
        List result = super.getSingleAssocs ();

        
        result.add("AssessmentLevel");
        
        result.add("ExpressAssessmentLevel");
        
        result.add("ParentOccupation");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return _AssessmentLevel.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return _ExpressAssessmentLevel.getReferencedType ();
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return _ParentOccupation.getReferencedType ();
        }
        else
        {
            return super.getSingleAssocReferenceInstance (assocName);
        }
    }


    public String getSingleAssocBackReference(String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return null ;
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return Occupation.MULTIPLEREFERENCE_ChildOccupations ;
        }
        else
        {
            return super.getSingleAssocBackReference (assocName);
        }
    }
    
    
    public BaseBusinessClass getSingleAssoc (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return getAssessmentLevel ();
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return getExpressAssessmentLevel ();
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return getParentOccupation ();
        }
        else
        {
            return super.getSingleAssoc (assocName);
        }
    }


    public BaseBusinessClass getSingleAssoc (String assocName, Get getType) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return getAssessmentLevel (getType);
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return getExpressAssessmentLevel (getType);
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return getParentOccupation (getType);
        }
        else
        {
            return super.getSingleAssoc (assocName, getType);
        }
    }


    public Long getSingleAssocID (String assocName) throws StorageException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return getAssessmentLevelID ();
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return getExpressAssessmentLevelID ();
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return getParentOccupationID ();
        }
        else
        {
            return super.getSingleAssocID (assocName);
        }
    }


    public void setSingleAssoc (String assocName, BaseBusinessClass newValue) throws StorageException, FieldException
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        else if (assocName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            setAssessmentLevel ((Level)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            setExpressAssessmentLevel ((Level)(newValue));
        }else if (assocName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            setParentOccupation ((Occupation)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * Get the reference AssessmentLevel
     */
    public Level getAssessmentLevel () throws StorageException
    {
        assertValid();
        
        try
        {
            return (Level)(_AssessmentLevel.get ());
        }
        catch (ClassCastException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Occupation:", this.getObjectID (), ", was trying to get Level:",  getAssessmentLevelID ());
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _AssessmentLevel.get ().getClass ());
            throw e;
        }
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Level getAssessmentLevel (Get getType) throws StorageException
    {
        assertValid();
        return _AssessmentLevel.get(getType);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getAssessmentLevelID ()
    {
        assertValid();
        
        if (_AssessmentLevel == null)
        {
            return null;
        }
        else
        {
            return _AssessmentLevel.getID ();
        }
    }

    /**
     * Called prior to the assoc changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preAssessmentLevelChange (Level newAssessmentLevel) throws FieldException
    {
    }


    /**
     * Called after the assoc changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postAssessmentLevelChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_AssessmentLevel ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference AssessmentLevel.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setAssessmentLevel (Level newAssessmentLevel) throws StorageException, FieldException
    {
        

        if (_AssessmentLevel.wouldReferencedChange (newAssessmentLevel))
        {
            assertValid();
            Debug.assertion (getWriteability_AssessmentLevel () != FieldWriteability.FALSE, "Assoc AssessmentLevel is not writeable");
            preAssessmentLevelChange (newAssessmentLevel);
            
                    _AssessmentLevel.set (newAssessmentLevel);
                
            postAssessmentLevelChange ();
        }
    }

    /**
     * Get the reference ExpressAssessmentLevel
     */
    public Level getExpressAssessmentLevel () throws StorageException
    {
        assertValid();
        
        try
        {
            return (Level)(_ExpressAssessmentLevel.get ());
        }
        catch (ClassCastException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Occupation:", this.getObjectID (), ", was trying to get Level:",  getExpressAssessmentLevelID ());
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _ExpressAssessmentLevel.get ().getClass ());
            throw e;
        }
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Level getExpressAssessmentLevel (Get getType) throws StorageException
    {
        assertValid();
        return _ExpressAssessmentLevel.get(getType);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getExpressAssessmentLevelID ()
    {
        assertValid();
        
        if (_ExpressAssessmentLevel == null)
        {
            return null;
        }
        else
        {
            return _ExpressAssessmentLevel.getID ();
        }
    }

    /**
     * Called prior to the assoc changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preExpressAssessmentLevelChange (Level newExpressAssessmentLevel) throws FieldException
    {
    }


    /**
     * Called after the assoc changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postExpressAssessmentLevelChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_ExpressAssessmentLevel ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference ExpressAssessmentLevel.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setExpressAssessmentLevel (Level newExpressAssessmentLevel) throws StorageException, FieldException
    {
        

        if (_ExpressAssessmentLevel.wouldReferencedChange (newExpressAssessmentLevel))
        {
            assertValid();
            Debug.assertion (getWriteability_ExpressAssessmentLevel () != FieldWriteability.FALSE, "Assoc ExpressAssessmentLevel is not writeable");
            preExpressAssessmentLevelChange (newExpressAssessmentLevel);
            
                    _ExpressAssessmentLevel.set (newExpressAssessmentLevel);
                
            postExpressAssessmentLevelChange ();
        }
    }

    /**
     * Get the reference ParentOccupation
     */
    public Occupation getParentOccupation () throws StorageException
    {
        assertValid();
        
        try
        {
            return (Occupation)(_ParentOccupation.get ());
        }
        catch (ClassCastException e)
        {
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Cache collision in Occupation:", this.getObjectID (), ", was trying to get Occupation:",  getParentOccupationID ());
            LogMgr.log (BUSINESS_OBJECTS, LogLevel.SYSTEMERROR2, "Instead I got:", _ParentOccupation.get ().getClass ());
            throw e;
        }
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Occupation getParentOccupation (Get getType) throws StorageException
    {
        assertValid();
        return _ParentOccupation.get(getType);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getParentOccupationID ()
    {
        assertValid();
        
        if (_ParentOccupation == null)
        {
            return null;
        }
        else
        {
            return _ParentOccupation.getID ();
        }
    }

    /**
     * Called prior to the assoc changing.  Subclasses need not call super.  If a field exception
     * is thrown, the attribute change will fail.  The new value is different to the old value.
     */
    protected void preParentOccupationChange (Occupation newParentOccupation) throws FieldException
    {
    }


    /**
     * Called after the assoc changes.
     * If a field exception is thrown, the value is still changed, however it 
     * may lead to the TX being rolled back
     */
    protected void postParentOccupationChange () throws FieldException
    {
    }



    
    public FieldWriteability getWriteability_ParentOccupation ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    /**
     * Set the reference ParentOccupation.  Checks to ensure a new value
     * has been supplied.  If so, marks the reference as altered and sets it.
     */
    public void setParentOccupation (Occupation newParentOccupation) throws StorageException, FieldException
    {
        

        if (_ParentOccupation.wouldReferencedChange (newParentOccupation))
        {
            assertValid();
            Debug.assertion (getWriteability_ParentOccupation () != FieldWriteability.FALSE, "Assoc ParentOccupation is not writeable");
            preParentOccupationChange (newParentOccupation);
            Occupation oldParentOccupation = getParentOccupation ();

                    if (oldParentOccupation != null)
                    {
                        // This is to stop validation from triggering when we are removed
                        _ParentOccupation.set (null);
                        oldParentOccupation.removeFromChildOccupations ((Occupation)(this));
                    }

                    _ParentOccupation.set (newParentOccupation);

                    if (newParentOccupation != null)
                    {
                        newParentOccupation.addToChildOccupations ((Occupation)(this));
                    }
                
            postParentOccupationChange ();
        }
    }

    /**
     * A list of multi assoc names e.g. list of strings.
     */
    public List<String> getMultiAssocs()
    {
        List result = super.getMultiAssocs ();

        
        result.add("ChildOccupations");
        

        return result;
    }


    /**
     * Get the reference instance for the multi assoc name.
     */
    public BaseBusinessClass getMultiAssocReferenceInstance(String attribName)
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            return Occupation.REFERENCE_Occupation ;
        }
        

        return super.getMultiAssocReferenceInstance(attribName);
    }


    public String getMultiAssocBackReference(String attribName)
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            return Occupation.SINGLEREFERENCE_ParentOccupation ;
        }
        

        return super.getMultiAssocBackReference(attribName);
    }


    /**
     * Get the assoc count for the multi assoc name.
     */
    public int getMultiAssocCount(String attribName) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            return this.getChildOccupationsCount();
        }
        

        return super.getMultiAssocCount(attribName);
    }


    /**
     * Get the assoc at a particular index
     */
    public BaseBusinessClass getMultiAssocAt(String attribName, int index) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            return this.getChildOccupationsAt(index);
        }
        

        return super.getMultiAssocAt(attribName, index);
    }


    /**
     * Add to a multi assoc by attribute name
     */
    public void addToMultiAssoc(String attribName, BaseBusinessClass newElement) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            addToChildOccupations((Occupation)newElement);

            return;
        }
        

        super.addToMultiAssoc(attribName, newElement);
    }

    /**
     * Remove from a multi assoc by attribute name
     */
    public void removeFromMultiAssoc(String attribName, BaseBusinessClass oldElement) throws StorageException
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            removeFromChildOccupations((Occupation)oldElement);

            return;
        }
        

        super.removeFromMultiAssoc(attribName, oldElement);
    }


    protected void __loadMultiAssoc (String attribName, BaseBusinessClass[] elements)
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            _ChildOccupations.__loadAssociation (elements);
            return;
        }
        

        super.__loadMultiAssoc(attribName, elements);
    }


    protected boolean __isMultiAssocLoaded (String attribName)
    {
        
        if (MULTIPLEREFERENCE_ChildOccupations.equals(attribName))
        {
            return _ChildOccupations.isLoaded ();
        }
        

        return super.__isMultiAssocLoaded(attribName);
    }

    

    public FieldWriteability getWriteability_ChildOccupations ()
    {
        return getFieldWritabilityUtil (FieldWriteability.TRUE);
    }
    
    
    public int getChildOccupationsCount () throws StorageException
    {
        assertValid();
        return _ChildOccupations.getReferencedObjectsCount ();
    }


    public void addToChildOccupations (Occupation newElement) throws StorageException
    {
        if (_ChildOccupations.wouldAddChange (newElement))
        {
            assertValid();
            Debug.assertion (getWriteability_ChildOccupations () != FieldWriteability.FALSE, "MultiAssoc ChildOccupations is not writeable (add)");
            _ChildOccupations.appendElement (newElement);

            try
            {
                if (newElement.getParentOccupation () != this)
                {
                    newElement.setParentOccupation ((Occupation)(this));
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public void removeFromChildOccupations (Occupation elementToRemove) throws StorageException
    {
        if (_ChildOccupations.wouldRemoveChange (elementToRemove))
        {
            assertValid();
            Debug.assertion (getWriteability_ChildOccupations () != FieldWriteability.FALSE, "MultiAssoc ChildOccupations is not writeable (remove)");
            _ChildOccupations.removeElement (elementToRemove);
            try
            {
                if (elementToRemove.getParentOccupation () != null)
                {
                    elementToRemove.setParentOccupation (null);
                }
            }
            catch (Exception e)
            {
                throw NestedException.wrap(e);
            }
        }
    }


    public Occupation getChildOccupationsAt (int index) throws StorageException
    {
        return (Occupation)(_ChildOccupations.getElementAt (index));
    }


    public SortedSet<Occupation> getChildOccupationsSet () throws StorageException
    {
        return _ChildOccupations.getSet ();
    }



    public void onDelete ()
    {
        try 
        {
            // Ensure we are removed from any loaded multi-associations that aren't mandatory
            if (_ParentOccupation.isLoaded () || getTransaction ().isObjectLoaded (_ParentOccupation.getReferencedType (), getParentOccupationID ()))
            {
                Occupation  referenced = getParentOccupation ();

                if (referenced != null)
                {
                    // Stop the callback
                    LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null ChildOccupations from ", getObjectID (), " to ", referenced.getObjectID ());
                    _ParentOccupation.set (null);
                    referenced.removeFromChildOccupations ((Occupation)this);
                }
            }
        
            for(Occupation referenced : CollectionUtils.reverse(getChildOccupationsSet()))
            { 
                LogMgr.log (BUSINESS_OBJECTS, LogLevel.DEBUG1, "Setting backreference to null ParentOccupation from ", getObjectID (), " to ", referenced.getObjectID ());
                referenced.setParentOccupation(null);
            }

        }
        catch (Exception e)
        {
            throw NestedException.wrap(e);
        }

        super.onDelete ();
    }


    public Occupation newInstance ()
    {
        return new Occupation ();
    }


    public Occupation referenceInstance ()
    {
        return REFERENCE_Occupation;
    }


    public Occupation getInTransaction (ObjectTransaction t) throws StorageException
    {
        return getOccupationByID (t, getObjectID());
    }
    
    
    public BaseBusinessClass dummyInstance ()
    {
        return DUMMY_Occupation;
    }


    public String getBaseSetName ()
    {
        return "tl_occupation";
    }





    /**
     * This is where an object returns the Persistent sets that will
     * store it into the database.
     * The should be entered into allSets
     */
    public void getPersistentSets (PersistentSetCollection allSets)
    {
        ObjectStatus        myStatus = getStatus ();
        PersistentSetStatus myPSetStatus = myStatus.getPSetStatus();
        ObjectID            myID = getID();

        super.getPersistentSets (allSets);

        
        PersistentSet   tl_occupationPSet = allSets.getPersistentSet (myID, "tl_occupation", myPSetStatus);

        tl_occupationPSet.setAttrib (FIELD_ObjectID, myID);
        tl_occupationPSet.setAttrib (FIELD_Code, HELPER_Code.toObject (_Code)); //
        tl_occupationPSet.setAttrib (FIELD_Name, HELPER_Name.toObject (_Name)); //
        tl_occupationPSet.setAttrib (FIELD_Level, HELPER_Level.toObject (_Level)); //
        tl_occupationPSet.setAttrib (FIELD_AssessmentType, HELPER_AssessmentType.toObject (_AssessmentType)); //
        tl_occupationPSet.setAttrib (FIELD_PartTimeAssessmentType, HELPER_PartTimeAssessmentType.toObject (_PartTimeAssessmentType)); //
        _AssessmentLevel.getPersistentSets (allSets);
        _ExpressAssessmentLevel.getPersistentSets (allSets);
        _ParentOccupation.getPersistentSets (allSets);
        
    }


    /**
     * Sets the objects state based on Persistent sets.
     */
    public void setFromPersistentSets (ObjectID objectID, PersistentSetCollection allSets)
    {
        super.setFromPersistentSets (objectID, allSets);

        
        PersistentSet   tl_occupationPSet = allSets.getPersistentSet (objectID, "tl_occupation");

        _Code = (String)(HELPER_Code.fromObject (_Code, tl_occupationPSet.getAttrib (FIELD_Code))); //
        _Name = (String)(HELPER_Name.fromObject (_Name, tl_occupationPSet.getAttrib (FIELD_Name))); //
        _Level = (OccupationLevel)(HELPER_Level.fromObject (_Level, tl_occupationPSet.getAttrib (FIELD_Level))); //
        _AssessmentType = (AssessmentType)(HELPER_AssessmentType.fromObject (_AssessmentType, tl_occupationPSet.getAttrib (FIELD_AssessmentType))); //
        _PartTimeAssessmentType = (AssessmentType)(HELPER_PartTimeAssessmentType.fromObject (_PartTimeAssessmentType, tl_occupationPSet.getAttrib (FIELD_PartTimeAssessmentType))); //
        _AssessmentLevel.setFromPersistentSets (objectID, allSets);
        _ExpressAssessmentLevel.setFromPersistentSets (objectID, allSets);
        _ParentOccupation.setFromPersistentSets (objectID, allSets);
        
    }





    public void setAttributesFrom (BaseBusinessClass other, MultiException e)
    {
        super.setAttributesFrom (other, e);

        if (other instanceof Occupation)
        {
            Occupation otherOccupation = (Occupation)other;
            
            try
            {
                setCode (otherOccupation.getCode ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setName (otherOccupation.getName ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setLevel (otherOccupation.getLevel ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setAssessmentType (otherOccupation.getAssessmentType ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
            try
            {
                setPartTimeAssessmentType (otherOccupation.getPartTimeAssessmentType ());
            }
            catch (FieldException ex)
            {
                e.addException (ex);
            }
            
        }
    }


    /**
     * Set the attributes in this to copies of the attributes in source.
     */
    public void copyAttributesFrom (BaseBusinessClass source)
    {
        super.copyAttributesFrom (source);

        if (source instanceof BaseOccupation)
        {
            BaseOccupation sourceOccupation = (BaseOccupation)(source);

            _Code = sourceOccupation._Code;
            _Name = sourceOccupation._Name;
            _Level = sourceOccupation._Level;
            _AssessmentType = sourceOccupation._AssessmentType;
            _PartTimeAssessmentType = sourceOccupation._PartTimeAssessmentType;
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copySingleAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copySingleAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseOccupation)
        {
            BaseOccupation sourceOccupation = (BaseOccupation)(source);

            _AssessmentLevel.copyFrom (sourceOccupation._AssessmentLevel, linkToGhosts);
            _ExpressAssessmentLevel.copyFrom (sourceOccupation._ExpressAssessmentLevel, linkToGhosts);
            _ParentOccupation.copyFrom (sourceOccupation._ParentOccupation, linkToGhosts);
            
        }
    }


    /**
     * Set the associations in this to copies of the attributes in source.
     */
    public void copyAssociationsFrom (BaseBusinessClass source, boolean linkToGhosts)
    {
        super.copyAssociationsFrom (source, linkToGhosts);

        if (source instanceof BaseOccupation)
        {
            BaseOccupation sourceOccupation = (BaseOccupation)(source);

            _ChildOccupations.copyFrom (sourceOccupation._ChildOccupations, linkToGhosts);
            
        }
    }


    public void validate (ValidationContext context)
    {
        super.validate (context);

        
    }


    /**
     * Subclasses must override this to read in their attributes
     */
    protected void readExternalData(Map<String, Object> vals) throws IOException, ClassNotFoundException
    {
        super.readExternalData(vals);

        _Code = (String)(HELPER_Code.readExternal (_Code, vals.get(FIELD_Code))); //
        _Name = (String)(HELPER_Name.readExternal (_Name, vals.get(FIELD_Name))); //
        _Level = (OccupationLevel)(HELPER_Level.readExternal (_Level, vals.get(FIELD_Level))); //
        _AssessmentType = (AssessmentType)(HELPER_AssessmentType.readExternal (_AssessmentType, vals.get(FIELD_AssessmentType))); //
        _PartTimeAssessmentType = (AssessmentType)(HELPER_PartTimeAssessmentType.readExternal (_PartTimeAssessmentType, vals.get(FIELD_PartTimeAssessmentType))); //
        _AssessmentLevel.readExternalData(vals.get(SINGLEREFERENCE_AssessmentLevel));
        _ExpressAssessmentLevel.readExternalData(vals.get(SINGLEREFERENCE_ExpressAssessmentLevel));
        _ParentOccupation.readExternalData(vals.get(SINGLEREFERENCE_ParentOccupation));
        _ChildOccupations.readExternalData(vals.get(MULTIPLEREFERENCE_ChildOccupations));
        
    }


    /**
     * Subclasses must override this to write out their attributes
     */
    protected void writeExternalData(Map<String, Object> vals) throws IOException
    {
        super.writeExternalData(vals);

        vals.put (FIELD_Code, HELPER_Code.writeExternal (_Code));
        vals.put (FIELD_Name, HELPER_Name.writeExternal (_Name));
        vals.put (FIELD_Level, HELPER_Level.writeExternal (_Level));
        vals.put (FIELD_AssessmentType, HELPER_AssessmentType.writeExternal (_AssessmentType));
        vals.put (FIELD_PartTimeAssessmentType, HELPER_PartTimeAssessmentType.writeExternal (_PartTimeAssessmentType));
        vals.put (SINGLEREFERENCE_AssessmentLevel, _AssessmentLevel.writeExternalData());
        vals.put (SINGLEREFERENCE_ExpressAssessmentLevel, _ExpressAssessmentLevel.writeExternalData());
        vals.put (SINGLEREFERENCE_ParentOccupation, _ParentOccupation.writeExternalData());
        vals.put (MULTIPLEREFERENCE_ChildOccupations, _ChildOccupations.writeExternalData());
        
    }


    public void compare (BaseBusinessClass other, AttributeChangeListener listener) throws StorageException
    {
        super.compare (other, listener);

        if (other instanceof BaseOccupation)
        {
            BaseOccupation otherOccupation = (BaseOccupation)(other);

            
            if (!HELPER_Code.compare(this._Code, otherOccupation._Code))
            {
                listener.notifyFieldChange(this, other, FIELD_Code, HELPER_Code.toObject(this._Code), HELPER_Code.toObject(otherOccupation._Code));
            }
            if (!HELPER_Name.compare(this._Name, otherOccupation._Name))
            {
                listener.notifyFieldChange(this, other, FIELD_Name, HELPER_Name.toObject(this._Name), HELPER_Name.toObject(otherOccupation._Name));
            }
            if (!HELPER_Level.compare(this._Level, otherOccupation._Level))
            {
                listener.notifyFieldChange(this, other, FIELD_Level, HELPER_Level.toObject(this._Level), HELPER_Level.toObject(otherOccupation._Level));
            }
            if (!HELPER_AssessmentType.compare(this._AssessmentType, otherOccupation._AssessmentType))
            {
                listener.notifyFieldChange(this, other, FIELD_AssessmentType, HELPER_AssessmentType.toObject(this._AssessmentType), HELPER_AssessmentType.toObject(otherOccupation._AssessmentType));
            }
            if (!HELPER_PartTimeAssessmentType.compare(this._PartTimeAssessmentType, otherOccupation._PartTimeAssessmentType))
            {
                listener.notifyFieldChange(this, other, FIELD_PartTimeAssessmentType, HELPER_PartTimeAssessmentType.toObject(this._PartTimeAssessmentType), HELPER_PartTimeAssessmentType.toObject(otherOccupation._PartTimeAssessmentType));
            }

            // Compare single assocs
            _AssessmentLevel.compare (otherOccupation._AssessmentLevel, listener);
            _ExpressAssessmentLevel.compare (otherOccupation._ExpressAssessmentLevel, listener);
            _ParentOccupation.compare (otherOccupation._ParentOccupation, listener);
            

            // Compare multiple assocs
            _ChildOccupations.compare (otherOccupation._ChildOccupations, listener);
            
        }
    }


    public void visitTransients (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        
    }


    public void visitAttributes (AttributeVisitor visitor) throws StorageException
    {
        super.visitAttributes (visitor);

        visitor.visitField(this, FIELD_Code, HELPER_Code.toObject(getCode()));
        visitor.visitField(this, FIELD_Name, HELPER_Name.toObject(getName()));
        visitor.visitField(this, FIELD_Level, HELPER_Level.toObject(getLevel()));
        visitor.visitField(this, FIELD_AssessmentType, HELPER_AssessmentType.toObject(getAssessmentType()));
        visitor.visitField(this, FIELD_PartTimeAssessmentType, HELPER_PartTimeAssessmentType.toObject(getPartTimeAssessmentType()));
        visitor.visitAssociation (_AssessmentLevel);
        visitor.visitAssociation (_ExpressAssessmentLevel);
        visitor.visitAssociation (_ParentOccupation);
        visitor.visitAssociation (_ChildOccupations);
        
    }


    public void visitAssociations (AssociationVisitor visitor, AssociatedScope scope) throws StorageException
    {
        super.visitAssociations (visitor, scope);

        if (scope.includes (_AssessmentLevel))
        {
            visitor.visit (_AssessmentLevel);
        }
        if (scope.includes (_ExpressAssessmentLevel))
        {
            visitor.visit (_ExpressAssessmentLevel);
        }
        if (scope.includes (_ParentOccupation))
        {
            visitor.visit (_ParentOccupation);
        }
        if (scope.includes (_ChildOccupations))
        {
            visitor.visit (_ChildOccupations);
        }
        
    }


    public static Occupation createOccupation (ObjectTransaction transaction) throws StorageException
    {
        Occupation     result = new Occupation ();

        result.initialiseNewObject (transaction);

        return result;
    }


    public static Occupation getOccupationByID (ObjectTransaction transaction, Long objectID) throws StorageException
    {
        return (Occupation)(transaction.getObjectByID (REFERENCE_Occupation, objectID));
    }

    public boolean testFilter (String attribName, QueryFilter filter) throws StorageException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Code))
        {
            return filter.matches (getCode ());
        }
        else if (attribName.equals (FIELD_Name))
        {
            return filter.matches (getName ());
        }
        else if (attribName.equals (FIELD_Level))
        {
            return filter.matches (getLevel ());
        }
        else if (attribName.equals (FIELD_AssessmentType))
        {
            return filter.matches (getAssessmentType ());
        }
        else if (attribName.equals (FIELD_PartTimeAssessmentType))
        {
            return filter.matches (getPartTimeAssessmentType ());
        }
        else if (attribName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return filter.matches (getAssessmentLevel ());
        }
        else if (attribName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return filter.matches (getExpressAssessmentLevel ());
        }
        else if (attribName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return filter.matches (getParentOccupation ());
        }
        else
        {
            return super.testFilter (attribName, filter);
        }
    }


    public static SearchAll SearchByAll () { return new SearchAll (); }

    public static class SearchAll extends SearchObject<Occupation>
    {
        
            public SearchAll andObjectID (QueryFilter<Long> filter)
            {
                filter.addFilter (context, "tl_occupation.object_id", FIELD_ObjectID);
                return this;
            }

            public SearchAll andObjectCreated (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "tl_occupation.object_created_date", FIELD_ObjectCreated);
                return this;
            }

            public SearchAll andObjectLastModified (QueryFilter<Date> filter)
            {
                filter.addFilter (context, "tl_occupation.object_last_updated_date", FIELD_ObjectLastModified);
                return this;
            }

            
            public SearchAll andCode (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_occupation.code", "Code");
                return this;
            }
            
            public SearchAll andName (QueryFilter<String> filter)
            {
                filter.addFilter (context, "tl_occupation.name", "Name");
                return this;
            }
            
            public SearchAll andLevel (QueryFilter<OccupationLevel> filter)
            {
                filter.addFilter (context, "tl_occupation.level", "Level");
                return this;
            }
            
            public SearchAll andAssessmentType (QueryFilter<AssessmentType> filter)
            {
                filter.addFilter (context, "tl_occupation.assessment_type", "AssessmentType");
                return this;
            }
            
            public SearchAll andPartTimeAssessmentType (QueryFilter<AssessmentType> filter)
            {
                filter.addFilter (context, "tl_occupation.parttime_assessment_type", "PartTimeAssessmentType");
                return this;
            }
            
            public SearchAll andAssessmentLevel (QueryFilter<Level> filter)
            {
                filter.addFilter (context, "tl_occupation.assessment_level_id", "AssessmentLevel");
                return this;
            }
            
            public SearchAll andExpressAssessmentLevel (QueryFilter<Level> filter)
            {
                filter.addFilter (context, "tl_occupation.express_assessment_level_id", "ExpressAssessmentLevel");
                return this;
            }
            
            public SearchAll andParentOccupation (QueryFilter<Occupation> filter)
            {
                filter.addFilter (context, "tl_occupation.parent_occupation_id", "ParentOccupation");
                return this;
            }
            
                public Occupation[]
             search (ObjectTransaction transaction) throws StorageException
        {
            
            
            BaseBusinessClass[]     results = super.search (transaction, REFERENCE_Occupation, SEARCH_All, criteria);
            Set<Occupation>   typedResults = new LinkedHashSet <Occupation> ();
            for (BaseBusinessClass bbcResult : results)
            {
                Occupation aResult = (Occupation)bbcResult;
                
                typedResults.add (aResult);
            }
            
                    return ObjstoreUtils.removeDeleted(transaction, typedResults).toArray (new Occupation[0]);
                            
        }
    }

        
                public static Occupation[]
             searchAll (ObjectTransaction transaction) throws StorageException
        {
            return SearchByAll ()
            .search (transaction);
        }



    public Object getAttribute (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Code))
        {
            return HELPER_Code.toObject (getCode ());
        }
        else if (attribName.equals (FIELD_Name))
        {
            return HELPER_Name.toObject (getName ());
        }
        else if (attribName.equals (FIELD_Level))
        {
            return HELPER_Level.toObject (getLevel ());
        }
        else if (attribName.equals (FIELD_AssessmentType))
        {
            return HELPER_AssessmentType.toObject (getAssessmentType ());
        }
        else if (attribName.equals (FIELD_PartTimeAssessmentType))
        {
            return HELPER_PartTimeAssessmentType.toObject (getPartTimeAssessmentType ());
        }
        else
        {
            return super.getAttribute (attribName);
        }
    }


    public AttributeHelper getAttributeHelper (String attribName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Code))
        {
            return HELPER_Code;
        }
        else if (attribName.equals (FIELD_Name))
        {
            return HELPER_Name;
        }
        else if (attribName.equals (FIELD_Level))
        {
            return HELPER_Level;
        }
        else if (attribName.equals (FIELD_AssessmentType))
        {
            return HELPER_AssessmentType;
        }
        else if (attribName.equals (FIELD_PartTimeAssessmentType))
        {
            return HELPER_PartTimeAssessmentType;
        }
        else
        {
            return super.getAttributeHelper (attribName);
        }
    }


    public void setAttribute (String attribName, Object attribValue) throws FieldException
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (attribName.equals (FIELD_Code))
        {
            setCode ((String)(HELPER_Code.fromObject (_Code, attribValue)));            
        }
        else if (attribName.equals (FIELD_Name))
        {
            setName ((String)(HELPER_Name.fromObject (_Name, attribValue)));            
        }
        else if (attribName.equals (FIELD_Level))
        {
            setLevel ((OccupationLevel)(HELPER_Level.fromObject (_Level, attribValue)));            
        }
        else if (attribName.equals (FIELD_AssessmentType))
        {
            setAssessmentType ((AssessmentType)(HELPER_AssessmentType.fromObject (_AssessmentType, attribValue)));            
        }
        else if (attribName.equals (FIELD_PartTimeAssessmentType))
        {
            setPartTimeAssessmentType ((AssessmentType)(HELPER_PartTimeAssessmentType.fromObject (_PartTimeAssessmentType, attribValue)));            
        }
        else
        {
            super.setAttribute (attribName, attribValue);
        }
    }



    public boolean isWriteable (String fieldName)
    {
        return getWriteable (fieldName) == FieldWriteability.TRUE;
    }


    public FieldWriteability getWriteable (String fieldName)
    {
        if (false)
        {
            throw new RuntimeException ("Game over man!!");
        }
        else if (fieldName.equals (FIELD_Code))
        {
            return getWriteability_Code ();
        }
        else if (fieldName.equals (FIELD_Name))
        {
            return getWriteability_Name ();
        }
        else if (fieldName.equals (FIELD_Level))
        {
            return getWriteability_Level ();
        }
        else if (fieldName.equals (FIELD_AssessmentType))
        {
            return getWriteability_AssessmentType ();
        }
        else if (fieldName.equals (FIELD_PartTimeAssessmentType))
        {
            return getWriteability_PartTimeAssessmentType ();
        }
        else if (fieldName.equals (MULTIPLEREFERENCE_ChildOccupations))
        {
            return getWriteability_ChildOccupations ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_AssessmentLevel))
        {
            return getWriteability_AssessmentLevel ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_ExpressAssessmentLevel))
        {
            return getWriteability_ExpressAssessmentLevel ();
        }
        else if (fieldName.equals (SINGLEREFERENCE_ParentOccupation))
        {
            return getWriteability_ParentOccupation ();
        }
        else
        {
            return super.getWriteable (fieldName);
        }
    }


    public void putUnwriteable (Set<String> fields)
    {
        
            if (getWriteability_Code () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Code);
            }
        
            if (getWriteability_Name () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Name);
            }
        
            if (getWriteability_Level () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_Level);
            }
        
            if (getWriteability_AssessmentType () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_AssessmentType);
            }
        
            if (getWriteability_PartTimeAssessmentType () != FieldWriteability.TRUE)
            {
                fields.add (FIELD_PartTimeAssessmentType);
            }
        

        super.putUnwriteable (fields);
    }

    public List<AbstractAttribute> getAttributes ()
    {
        List result = super.getAttributes ();

        
        result.add(HELPER_Code.getAttribObject (getClass (), _Code, true, FIELD_Code));
        result.add(HELPER_Name.getAttribObject (getClass (), _Name, true, FIELD_Name));
        result.add(HELPER_Level.getAttribObject (getClass (), _Level, true, FIELD_Level));
        result.add(HELPER_AssessmentType.getAttribObject (getClass (), _AssessmentType, false, FIELD_AssessmentType));
        result.add(HELPER_PartTimeAssessmentType.getAttribObject (getClass (), _PartTimeAssessmentType, false, FIELD_PartTimeAssessmentType));

        return result;
    }


    public Map getAttributeMetadata (String attribute)
    {
        if (ATTRIBUTES_METADATA_Occupation.containsKey (attribute))
        {
            return (Map)ATTRIBUTES_METADATA_Occupation.get (attribute);
        }
        else
        {
            return super.getAttributeMetadata (attribute);
        }
    }


    public Object getAttributeMetadata (String attribute, String metadata)
    {
        if (ATTRIBUTES_METADATA_Occupation.containsKey (attribute))
        {
            return ((Map)ATTRIBUTES_METADATA_Occupation.get (attribute)).get(metadata);
        }
        else
        {
            return super.getAttributeMetadata (attribute, metadata);
        }
    }

    public void preCommit (boolean willBeStored) throws Exception
    {
        super.preCommit(willBeStored);
        
        if(willBeStored)
        {
        
        }
    }

    public oneit.servlets.objstore.binary.BinaryContentHandler getBinaryContentHandler(String attribName)
    {
        
        
        return super.getBinaryContentHandler(attribName);
    }

    public static class OccupationBehaviourDecorator extends BaseBusinessClass.BBCBehaviourDecorator<Occupation>
    {

    /**
     * Get the attribute Code
     */
    public String getCode (Occupation obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Code.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setCode (Occupation obj, String newCode) throws FieldException
    {
        return newCode;
    }

    /**
     * Get the attribute Name
     */
    public String getName (Occupation obj, String original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Name.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public String setName (Occupation obj, String newName) throws FieldException
    {
        return newName;
    }

    /**
     * Get the attribute Level
     */
    public OccupationLevel getLevel (Occupation obj, OccupationLevel original)
    {
        return original;
    }

    /**
     * Change the value set for attribute Level.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public OccupationLevel setLevel (Occupation obj, OccupationLevel newLevel) throws FieldException
    {
        return newLevel;
    }

    /**
     * Get the attribute AssessmentType
     */
    public AssessmentType getAssessmentType (Occupation obj, AssessmentType original)
    {
        return original;
    }

    /**
     * Change the value set for attribute AssessmentType.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public AssessmentType setAssessmentType (Occupation obj, AssessmentType newAssessmentType) throws FieldException
    {
        return newAssessmentType;
    }

    /**
     * Get the attribute PartTimeAssessmentType
     */
    public AssessmentType getPartTimeAssessmentType (Occupation obj, AssessmentType original)
    {
        return original;
    }

    /**
     * Change the value set for attribute PartTimeAssessmentType.
     * May modify the field beforehand
     * Occurs before validation.
     */
    public AssessmentType setPartTimeAssessmentType (Occupation obj, AssessmentType newPartTimeAssessmentType) throws FieldException
    {
        return newPartTimeAssessmentType;
    }

    }

    
    public ORMPipeLine pipes()
    {
        return new OccupationPipeLineFactory<Occupation, Occupation> ((Occupation)this);
    }
      
    /**
     * Use this instead of pipes() to get rid of type casting.
     */  
    public OccupationPipeLineFactory<Occupation, Occupation> pipelineOccupation()
    {
        return (OccupationPipeLineFactory<Occupation, Occupation>) pipes();
    }
    
    public static OccupationPipeLineFactory<Occupation, Occupation> pipesOccupation(Collection<Occupation> items)
    {
        return REFERENCE_Occupation.new OccupationPipeLineFactory<Occupation, Occupation> (items);
    }
    
    public static OccupationPipeLineFactory<Occupation, Occupation> pipesOccupation(Occupation[] _items)
    {
        return pipesOccupation(Arrays.asList (_items));
    }
    
    public static OccupationPipeLineFactory<Occupation, Occupation> pipesOccupation()
    {
        return pipesOccupation((Collection)null);
    }
    
    
    public class OccupationPipeLineFactory<From extends BaseBusinessClass, Me extends Occupation> extends BaseBusinessClass.ORMPipeLine<From, Me>    
    {
        public <Prev> OccupationPipeLineFactory (PipeLine<From, Prev> pipeLine, Pipe<Prev, Me> nextPipe)
        {
            super (pipeLine, nextPipe);
        }
        
        public OccupationPipeLineFactory (From seed)
        {
            super(seed);
        }

        public OccupationPipeLineFactory (Collection<From> seed)
        {
            super(seed);
        }
        
        
        public PipeLine<From, ? extends Object> to(String name)
        {
            if (name.equals ("ChildOccupations"))
            {
                return toChildOccupations ();
            }                
            if (name.equals ("Code"))
            {
                return toCode ();
            }                
            if (name.equals ("Name"))
            {
                return toName ();
            }                
            if (name.equals ("Level"))
            {
                return toLevel ();
            }                
            if (name.equals ("AssessmentType"))
            {
                return toAssessmentType ();
            }                
            if (name.equals ("PartTimeAssessmentType"))
            {
                return toPartTimeAssessmentType ();
            }                
            if (name.equals ("AssessmentLevel"))
            {
                return toAssessmentLevel ();
            }                
            if (name.equals ("ExpressAssessmentLevel"))
            {
                return toExpressAssessmentLevel ();
            }                
            if (name.equals ("ParentOccupation"))
            {
                return toParentOccupation ();
            }                
            
            
            return super.to(name);
        }
        
        
        public PipeLine<From, String> toCode () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Code));  }
        
        public PipeLine<From, String> toName () { return pipe(new ORMAttributePipe<Me, String>(FIELD_Name));  }
        
        public PipeLine<From, OccupationLevel> toLevel () { return pipe(new ORMAttributePipe<Me, OccupationLevel>(FIELD_Level));  }
        
        public PipeLine<From, AssessmentType> toAssessmentType () { return pipe(new ORMAttributePipe<Me, AssessmentType>(FIELD_AssessmentType));  }
        
        public PipeLine<From, AssessmentType> toPartTimeAssessmentType () { return pipe(new ORMAttributePipe<Me, AssessmentType>(FIELD_PartTimeAssessmentType));  }
        public Level.LevelPipeLineFactory<From, Level> toAssessmentLevel () { return toAssessmentLevel (Filter.ALL); }

        public Level.LevelPipeLineFactory<From, Level> toAssessmentLevel (Filter<Level> filter) 
        { 
            return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_AssessmentLevel, filter)); 
        }
        public Level.LevelPipeLineFactory<From, Level> toExpressAssessmentLevel () { return toExpressAssessmentLevel (Filter.ALL); }

        public Level.LevelPipeLineFactory<From, Level> toExpressAssessmentLevel (Filter<Level> filter) 
        { 
            return Level.REFERENCE_Level.new LevelPipeLineFactory<From, Level> (this, new ORMSingleAssocPipe<Me, Level>(SINGLEREFERENCE_ExpressAssessmentLevel, filter)); 
        }
        public Occupation.OccupationPipeLineFactory<From, Occupation> toParentOccupation () { return toParentOccupation (Filter.ALL); }

        public Occupation.OccupationPipeLineFactory<From, Occupation> toParentOccupation (Filter<Occupation> filter) 
        { 
            return Occupation.REFERENCE_Occupation.new OccupationPipeLineFactory<From, Occupation> (this, new ORMSingleAssocPipe<Me, Occupation>(SINGLEREFERENCE_ParentOccupation, filter)); 
        }
        public Occupation.OccupationPipeLineFactory<From, Occupation> toChildOccupations () { return toChildOccupations(Filter.ALL); }        

        public Occupation.OccupationPipeLineFactory<From, Occupation> toChildOccupations (Filter<Occupation> filter)
        {
            return Occupation.REFERENCE_Occupation.new OccupationPipeLineFactory<From, Occupation> (this, new ORMMultiAssocPipe<Me, Occupation>(MULTIPLEREFERENCE_ChildOccupations, filter)); 
        }
        
    }
    
    public boolean isTransientAttrib(String attribName)
    {
        

        return super.isTransientAttrib(attribName);
    }

    public boolean isTransientSingleReference(String assocName)
    {
        

        return super.isTransientSingleReference(assocName);
    }
}

class DummyOccupation extends Occupation
{
    // Default constructor primarily to support Externalisable
    public DummyOccupation()
    {
        super();
    }

    public void assertValid ()
    {
    }


    public Level getAssessmentLevel () throws StorageException
    {
        return (Level)(Level.DUMMY_Level);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getAssessmentLevelID ()
    {
        return Level.DUMMY_Level.getObjectID();
    }

    public Level getExpressAssessmentLevel () throws StorageException
    {
        return (Level)(Level.DUMMY_Level);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getExpressAssessmentLevelID ()
    {
        return Level.DUMMY_Level.getObjectID();
    }

    public Occupation getParentOccupation () throws StorageException
    {
        return (Occupation)(Occupation.DUMMY_Occupation);
    }


    /**
     * Get the object id for the referenced object.  Does not force a DB access.
     */
    public Long getParentOccupationID ()
    {
        return Occupation.DUMMY_Occupation.getObjectID();
    }

    public int getChildOccupationsCount () throws StorageException
    {
        return 0;
    }


    public Occupation getChildOccupationsAt (int index) throws StorageException
    {
        throw new RuntimeException ("No elements in a dummy object in association ChildOccupations");
    }


    public SortedSet getChildOccupationsSet () throws StorageException
    {
        return new TreeSet();
    }

}

