package org.objectweb.jonas.jtests.beans.ejbql;

import javax.ejb.CreateException;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import javax.naming.InitialContext;

public abstract class CreditCompanyBean implements javax.ejb.EntityBean {

    private SequenceSessionLocal  seqLocal = null;

    public Integer ejbCreate(String name) throws CreateException {
        int id = seqLocal.getNextNumberInSequence("CreditCompany");
	setId(new Integer(id));
	setName(name);
	setNum(id);
	return null;
    }
	
    public void ejbPostCreate( String name) {
    }

    // persistent fields

    public abstract void setId(Integer id);
    public abstract Integer getId();
    public abstract void setName(String name);
    public abstract String getName( );
    public abstract void setNum(int num);
    public abstract int getNum( );

    // relationship fields

    public abstract AddressLocal getAddress( );	
    public abstract void setAddress(AddressLocal cust);	

    // standard call back methods
    
    public void setEntityContext(EntityContext ec){
	try {
	    InitialContext cntx = new InitialContext( );
	    SequenceSessionLocalHome  seqHome  = 
		    (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome");
	    seqLocal = seqHome.create();
	} catch(Exception e) {
	    throw new javax.ejb.EJBException(e);
	}
}
    public void unsetEntityContext(){}
    public void ejbLoad(){}
    public void ejbStore(){}
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void ejbRemove() throws RemoveException {}

}
