/*
 * 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 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 attributes corresponding to business object data
    private String _Code;
    private String _Name;
    private OccupationLevel _Level;
    

    // Private attributes corresponding to single references
    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;
    

    // 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_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]);
            

            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_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;
    }
    
    // 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));
    }


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

        _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 ();
        
        _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 ();
        }
    }



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

        
        result.add("ParentOccupation");
        

        return result;
    }
    
    
    public BaseBusinessClass getSingleAssocReferenceInstance (String assocName)
    {
        if (assocName == null)
        {
            throw new RuntimeException ("Game over == null!");
        }
        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_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_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_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_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_ParentOccupation))
        {
            setParentOccupation ((Occupation)(newValue));
        }
        else
        {
            super.setSingleAssoc (assocName, newValue);
        }
    }



    /**
     * 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)); //
        _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))); //
        _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);
            }
            
        }
    }


    /**
     * 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;
            
        }
    }


    /**
     * 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);

            _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))); //
        _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 (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));
            }

            // Compare single assocs
            _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.visitAssociation (_ParentOccupation);
        visitor.visitAssociation (_ChildOccupations);
        
    }


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

        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 (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 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
        {
            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
        {
            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
        {
            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 (MULTIPLEREFERENCE_ChildOccupations))
        {
            return getWriteability_ChildOccupations ();
        }
        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);
            }
        

        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));

        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;
    }

    }

    
    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 ("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 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 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();
    }

}

