KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > ejbql > CreditCompanyBean


1 package org.objectweb.jonas.jtests.beans.ejbql;
2
3 import javax.ejb.CreateException JavaDoc;
4 import javax.ejb.EntityContext JavaDoc;
5 import javax.ejb.RemoveException JavaDoc;
6 import javax.naming.InitialContext JavaDoc;
7
8 public abstract class CreditCompanyBean implements javax.ejb.EntityBean JavaDoc {
9
10     private SequenceSessionLocal seqLocal = null;
11
12     public Integer JavaDoc ejbCreate(String JavaDoc name) throws CreateException JavaDoc {
13         int id = seqLocal.getNextNumberInSequence("CreditCompany");
14     setId(new Integer JavaDoc(id));
15     setName(name);
16     setNum(id);
17     return null;
18     }
19     
20     public void ejbPostCreate( String JavaDoc name) {
21     }
22
23     // persistent fields
24

25     public abstract void setId(Integer JavaDoc id);
26     public abstract Integer JavaDoc getId();
27     public abstract void setName(String JavaDoc name);
28     public abstract String JavaDoc getName( );
29     public abstract void setNum(int num);
30     public abstract int getNum( );
31
32     // relationship fields
33

34     public abstract AddressLocal getAddress( );
35     public abstract void setAddress(AddressLocal cust);
36
37     // standard call back methods
38

39     public void setEntityContext(EntityContext JavaDoc ec){
40     try {
41         InitialContext JavaDoc cntx = new InitialContext JavaDoc( );
42         SequenceSessionLocalHome seqHome =
43             (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome");
44         seqLocal = seqHome.create();
45     } catch(Exception JavaDoc e) {
46         throw new javax.ejb.EJBException JavaDoc(e);
47     }
48 }
49     public void unsetEntityContext(){}
50     public void ejbLoad(){}
51     public void ejbStore(){}
52     public void ejbActivate(){}
53     public void ejbPassivate(){}
54     public void ejbRemove() throws RemoveException JavaDoc {}
55
56 }
57
Popular Tags