## ---------------------------------------------------------------------------
## JOnAS: Java(TM) Open Application Server
## Copyright (C) 1999-2006 Bull S.A.
## Contact: jonas-team@objectweb.org
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this library; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
## USA
##
## Initial developer(s): Philippe Durieux, Helene Joanin.
##
## ---------------------------------------------------------------------------
## $Id$
## ---------------------------------------------------------------------------

// This class is the bean specific part of JEntityHome
// Generated by GenIC via Velocity. Do not edit directly this file.
// Start: $Id$

#if ($package.length() != 0)
package $package;
#end

import java.lang.Error;
import java.lang.Object;
import java.lang.RuntimeException;
import java.rmi.RemoteException;
import java.rmi.AccessException;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

import javax.ejb.EJBException;
import javax.ejb.FinderException;
import javax.ejb.Handle;
import javax.ejb.RemoveException;

import org.ow2.carol.rmi.exception.RmiUtility;
import org.ow2.carol.util.configuration.ConfigurationRepository;

import org.ow2.jonas.lib.ejb21.JEntityContext;
import org.ow2.jonas.lib.ejb21.JEntityFactory;
import org.ow2.jonas.lib.ejb21.JEntityHandle;
import org.ow2.jonas.lib.ejb21.JEntityHome;
import org.ow2.jonas.lib.ejb21.JEntityRemote;
import org.ow2.jonas.lib.ejb21.JEntitySwitch;
import org.ow2.jonas.lib.ejb21.ha.JRepEntityHome;
import org.ow2.jonas.lib.ejb21.RequestCtx;
import org.ow2.jonas.lib.ejb21.TraceEjb;
import org.ow2.jonas.deployment.ejb.EntityDesc;
import org.ow2.jonas.lib.ejb21.CollectionEnum;
import org.ow2.jonas.lib.ejb21.EJBInvocation;
import org.ow2.jonas.lib.svc.JHandleIIOP;
import org.objectweb.util.monolog.api.BasicLevel;
#if ($EntityCMP2.booleanValue())
import org.objectweb.jorm.api.PException;
import org.objectweb.jorm.api.PClassMapping;
import org.objectweb.jorm.naming.api.PName;
import org.ow2.jonas.lib.ejb21.jorm.Coder;
import org.ow2.jonas.lib.ejb21.jorm.PObject;
import org.ow2.jonas.lib.ejb21.jorm.PObjectHome;

public class $class
#if ($isClusterReplicated)
    extends JRepEntityHome
#else
    extends JEntityHome
#end
    implements Coder, PObjectHome, $home {
#else

public class $class
#if ($isClusterReplicated)
    extends JRepEntityHome
#else
    extends JEntityHome
#end
    implements $home {

#end


  // JOnAS version used to deploy
    public static final String JONAS_VERSION = "$jVersion";

    /**
     * Created by JEntityFactory (by newInstance)
     */
    public $class(EntityDesc dd, JEntityFactory bf) throws RemoteException {

      super(dd, bf);

    }

#foreach ($M in $methodList)

#if ($M.isCreate())

    /**
      * create method
      */
  public $M.getReturnType() $M.getName()($M.getFormalParameters()) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        boolean mapped = false;
        try {
            bs = ef.getJEntitySwitch();
            bctx = ef.getJContext(bs);
            bctx.setEntitySwitch(bs);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);

            rctx.bmcalled = true;
            #if ($EntityCMP2.booleanValue())
            Object pk = b._ejb$M.getCapName()($M.getActualParameters());
            #else
            Object pk = b.ejb$M.getCapName()($M.getActualParameters());
            #end
            bctx.setActive();
            boolean pkadded = ef.rebindEJB(rctx.currTx, bctx, pk);
            bs.bindICtx(rctx.currTx, bctx);
            mapped = true;
            bctx.setNewInstance();
            try {
                b.ejbPost$M.getCapName()($M.getActualParameters());
            } catch (EJBException e) {
              if (pkadded) {
                  bs.forceDiscardICtx(rctx.currTx);
                  bctx = null;
                }
                throw e;
            }
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            if (! mapped && bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }

        return ($remote) bs.getRemote();
        #afterThrowRemoteException()

  }

#elseif ($M.isFinderCol())

    /**
     * Finder method returning a Collection
     */
    public Collection $M.getName()($M.getFormalParameters()) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        Vector v = new Vector();
        Collection pkl;
        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        boolean mapped = false;
        try {
            ef.syncForFind(rctx.currTx);
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);
            bctx.setFinding();
            rctx.bmcalled = true;
            pkl = b.ejb$M.getCapName()($M.getActualParameters());
            bctx.setActive();
            Iterator pki = pkl.iterator();
            while (pki.hasNext()) {

                Object _pk = pki.next();

                #if ($EntityCMP2.booleanValue())
                // Fix bug #300526
                PName pn = (PName) _pk;
                if ((pn == null) || (pn.isNull())) {
                  v.addElement(null);
                } else
                #end
                {
                  bs = ef.getEJB(_pk);
                    if (!mapped) {
                        mapped = bs.tryBindICtx(rctx.currTx, bctx, false);
                    }
                    v.addElement(bs.getRemote());
                }
            }

        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            if (! mapped && bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }
        return v;

        #afterThrowRemoteException()

    }

#elseif ($M.isFinderEnum())

    /**
     * Finder method returning an Enumeration
     */
    public Enumeration $M.getName()($M.getFormalParameters()) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        CollectionEnum v = new CollectionEnum();
        boolean mapped = false;
        Enumeration pkl;
        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        try {
            ef.syncForFind(rctx.currTx);
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);
            bctx.setFinding();
            rctx.bmcalled = true;
            pkl = b.ejb$M.getCapName()($M.getActualParameters());
            bctx.setActive();
            while (pkl.hasMoreElements()) {
                Object _pk = pkl.nextElement();

                #if ($EntityCMP2.booleanValue())
                // Fix bug #300526
                PName pn = (PName) _pk;
                if ((pn == null) || (pn.isNull())) {
                    v.addElement(null);
                } else
                #end
                {
                    bs = ef.getEJB(_pk);
                    if (!mapped) {
                        mapped = bs.tryBindICtx(rctx.currTx, bctx, false);
                    }
                    v.addElement(bs.getRemote());
                }
            }
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            if (! mapped && bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }
        return v;

        #afterThrowRemoteException()
    }

#elseif ($M.isFinderSimple())

    /**
     * finder method returning only 1 PK
     */
    public $M.getReturnType() $M.getName()($M.getFormalParameters()) throws $M.getExceptionList() {

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        boolean mapped = false;
        try {
            ef.syncForFind(rctx.currTx);
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);
            bs = ef.getJEntitySwitch();
            bctx.setEntitySwitch(bs);
            bctx.setFinding();
            rctx.bmcalled = true;
            Object pk = b.ejb$M.getCapName()($M.getActualParameters());
            #if ($EntityCMP2.booleanValue())
            // Fix bug #300526
            PName pn = (PName) pk;
            if ((pn == null) || (pn.isNull())) {
              return null;
            }
            #end
            bctx.setActive();
            JEntitySwitch old = ef.existEJB(pk, bs, false);
            if (old != null) {
                bs = old;
                bctx.setEntitySwitch(bs);
            }
            mapped = bs.tryBindICtx(rctx.currTx, bctx, true);
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            if (! mapped && bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }

        return ($remote) bs.getRemote();

        #afterThrowRemoteException()
  }

#elseif ($M.isFinderByPk())

    /**
     * findByPrimaryKey
     */
    public $M.getReturnType() $M.getName()($M.getFormalParameters()) throws $M.getExceptionList() {

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        boolean mapped = false;
        try {
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);
            bs = ef.getJEntitySwitch();
            bctx.setEntitySwitch(bs);
            bctx.setFinding();
            rctx.bmcalled = true;
            Object pk =
#if ($EntityCMP2.booleanValue())
              decode($M.getActualParameters());
#else
              $M.getActualParameters();
#end
            JEntitySwitch old = ef.existEJB(pk, bs, true);
            if (old != null) {
                bs = old;
                bctx.setEntitySwitch(bs);
            } else {
                try {
                    pk = b.ejb$M.getCapName()(($pk) $M.getActualParameters());
                } catch (FinderException e) {
                    bs.forceDiscardICtx(rctx.currTx);
                    throw e;
                }
                ef.startEJB(pk);
            }
            bctx.setActive();
            mapped = bs.tryBindICtx(rctx.currTx, bctx, true);
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
#if ($EntityCMP2.booleanValue())
        } catch (org.objectweb.jorm.api.PException e) {
            rctx.sysExc = e;
            throw new RemoteException("decoding PK failed", e);
#end
        } finally {
            if (! mapped && bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }

        return ($remote) bs.getRemote();

        #afterThrowRemoteException()
  }

#elseif ($M.isRemovePk())

    /**
     * Remove by PK
     * @throws RemoveException
     */
    public void remove(Object p1) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        boolean mapped = false;
        try {
            ef.dummyFinderException(true);
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);

            #if ($EntityCMP2.booleanValue())
            Object pk = decode(($pk) p1);
            bs = ef.getEJB(pk);
            bctx.setEntitySwitch(bs);
            b.ejbFindByPrimaryKey((PName)pk);
            #else
            bs = ef.getEJB(p1);
            bctx.setEntitySwitch(bs);
            b.ejbFindByPrimaryKey(($pk) p1);
            #end

            bctx = bs.getICtx(rctx.currTx, bctx);
            // Must set this before setRemove() because exception may
            // occur in ejbRemove, and in that case, we must keep the context.
            mapped = true;
            rctx.bmcalled = true;
            bctx.setRemoved();
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        #if ($EntityCMP2.booleanValue())
        } catch (PException e) {
            rctx.sysExc = e;
            throw new RemoteException("JORM PException thrown", e);
        #end
        } catch (FinderException e) {
            rctx.sysExc = e;
            throw new RemoteException(e.toString());
        } finally {
            if (!mapped && bctx != null) {
                // release context in case of exception.
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }

        #afterThrowRemoteException()

    }

#elseif ($M.isRemoveHandle())

    /**
     * remove by Handle
     * @throws RemoveException
     */
    public void remove(Handle p1) throws $M.getExceptionList() {

        //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntitySwitch bs = null;
        JEntityFactory ef = (JEntityFactory) bf;
        JEntityContext bctx = null;
        try {
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            Object pk = null;
            checkSecurity(ejbInv);

            // Get the PK embedded inside the Handle
            String protocol = ConfigurationRepository.getCurrentConfiguration().getProtocol().getName();

            //TraceEjb.interp.log(BasicLevel.DEBUG, "Current protocol=" + protocol);
            #if ($EntityCMP2.booleanValue())
            if (protocol.equals("iiop")) {
                pk = decode(($pk) ((JHandleIIOP) p1).getEJBObject().getPrimaryKey());
            } else {
                pk = decode(($pk) ((JEntityHandle) p1).getPK());
            }
            #else
            if (protocol.equals("iiop")) {
                pk = ((JHandleIIOP) p1).getEJBObject().getPrimaryKey();
            } else {
                pk = ((JEntityHandle) p1).getPK();
            }
            #end

            bs = ef.getEJB(pk);
            bctx = bs.getICtx(rctx.currTx, bctx);
            rctx.bmcalled = true;
            bctx.setRemoved();
        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException(e.getMessage());
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        #if ($EntityCMP2.booleanValue())
        } catch (PException e) {
            rctx.sysExc = e;
            throw new RemoteException("JORM PException thrown", e);
        #end
        } finally {
            postInvoke(rctx);
        }

        #afterThrowRemoteException()

    }

#else

    /**
     * Home Method
     */
    public $M.getReturnType() $M.getName()($M.getFormalParameters())

    #if ( $M.getExceptionList().length() > 0 )
      throws $M.getExceptionList()
    #end
    {

    //TraceEjb.interp.log(BasicLevel.DEBUG, "");

        #beforeThrowRemoteException()

        EJBInvocation ejbInv = new EJBInvocation();
        ejbInv.methodPermissionSignature = "$M.getSecuritySignature()";
        ejbInv.arguments = $M.getArrayObjectParameters();
        RequestCtx rctx = preInvoke($M.getTxAttribute());
        JEntityFactory ef = (JEntityFactory) bf;

        #if ($M.getReturnType() != "void")
        $M.getReturnType() result;
        #end

        JEntityContext bctx = null;
        try {
            bctx = ef.getJContext(null);
            $bean_wrp b = ($bean_wrp) bctx.getInstance();
            ejbInv.bean = b;
            checkSecurity(ejbInv);
            rctx.bmcalled = true;

            #if ($M.getReturnType() != "void")
            result =
            #end
            b.ejbHome$M.getCapName()($M.getActualParameters());

        } catch (javax.ejb.AccessLocalException e) {
            throw new AccessException("Security Exception thrown by an enterprise Bean", e);
        } catch (RuntimeException e) {
            rctx.sysExc = e;
            throw new RemoteException("RuntimeException thrown by an enterprise Bean", e);
        } catch (Error e) {
            rctx.sysExc = e;
            throw new RemoteException("Error thrown by an enterprise Bean", e);
        } catch (RemoteException e) {
            rctx.sysExc = e;
            throw e;
        } finally {
            if (bctx != null) {
                ef.releaseJContext(bctx);
            }
            postInvoke(rctx);
        }

        #if ($M.getReturnType() != "void")
        return result;
        #end

        #afterThrowRemoteException()

  }

#end

#end

    public JEntityRemote createRemoteObject() throws RemoteException {

        #beforeThrowRemoteException()

        return new $remote_wrp((JEntityFactory)bf);

        #afterThrowRemoteException()

    }


#if ($EntityCMP2.booleanValue())

    /**
     * CMP2 methods :
     * ==============
     * In our case it has been choosen that the container (the generic part)
     * manages PName. This is the generated objects which do the translation
     * between PName and PK
     */

    // IMPLEMENTATION OF THE Coder INTERFACE //
    /**
     * This method build a PName with the primary key specifed in parameter.
     * To build the pname the PNamingContext associated to the bean is used.
     * Futhermore the PKFieldExtractor class is used as a specific PNameGetter
     * in case of the PName is composite (several fields).
     */
    public PName decode(Object pk)
        throws PException, UnsupportedOperationException {
        if (pk == null) {
            return ((PClassMapping) bf).getPBinder().getNull();
        }

#**##if($pkIsUserClass.booleanValue())
            return ((PClassMapping) bf).getPBinder().decodeAbstract(
                                                                    new PkFieldExtractor(($pk) pk), null);
#**##else ## Pk is a java.lang class (String, Long, ...)
            return ((PClassMapping) bf).getPBinder().$pkDecodeMethod;
#**##end

    }

    /**
     * This method build a primary key with the PName specifed in parameter.
     * To build the primary key the PNamingContext associated to the bean is
     * used. In case of the PName is composite (several fields), the
     * encodeAbstract must return a specific PNameGetter.
     */
    public Object encode(PName pn)
        throws PException, UnsupportedOperationException {
        if (pn==null || pn.isNull()) {
            return null;
        }

#**##if($pkIsUserClass.booleanValue())
            $pk pk = new $pk();
            ${dd.getJormPNameGetterClassName()} png = (${dd.getJormPNameGetterClassName()})
                                                    ((PClassMapping) bf).getPBinder().encodeAbstract(pn);
#*      *##foreach ($pkf in $fieldPkList)
#*        *##if (!$pkf.isMustBeConvert())
            pk.${pkf.getName()} = png.pnGet${pkf.getNameUpperFirst()}(null);
#*        *##else
            pk.${pkf.getName()} = (${pkf.getTypeName()})${pkf.getConvertClassName()}.toMemory((png.pnGet${pkf.getNameUpperFirst()}(null)));
#*        *##end

#*      *##end
            return pk;
#**##else ## Pk is a java.lang class (String, Long, ...)
            return $pkMappingToMemoryMethod(((PClassMapping) bf).getPBinder().$pkEncodeMethod(pn));
#**##end

  }

#**##if($pkIsUserClass.booleanValue())
    /**
     * This class is used to decode a primary key into a PName. It is
     * specilized to the name structure
     */
    private class PkFieldExtractor implements ${dd.getJormPNameGetterClassName()} {

      $pk pk;
      public PkFieldExtractor($pk pk) {
          this.pk = pk;
      }
#*      *##foreach ($pkf in $fieldPkList)
      public ${pkf.getJormTypeName()} pnGet${pkf.getNameUpperFirst()}(Object ctx) {
#*          *##if (!$pkf.isMustBeConvert())
            return pk.${pkf.getName()};
#*          *##else
            return (${pkf.getJormTypeName()})${pkf.getConvertClassName()}.toStorage((pk.${pkf.getName()}));
#*          *##end
      }
#*      *##end
  }
#**##end

    // IMPLEMENTATION OF THE PObjectHome INTERFACE //

    public PObject getPObject(PName pn) {
        return (PObject) ((JEntityFactory) bf).getEJB(pn).getRemote();
    }
#end ##EntityCMP2

}
// End: $Id$

