KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.jonas.jtests.beans.ejbql;
2
3 import java.util.Date JavaDoc;
4
5 import javax.ejb.EntityContext JavaDoc;
6 import javax.naming.InitialContext JavaDoc;
7
8 public abstract class CreditCardBean implements javax.ejb.EntityBean JavaDoc {
9     private SequenceSessionLocalHome seqHome = null;
10     private SequenceSessionLocal seqLocal = null;
11
12     public Object JavaDoc ejbCreate(Date JavaDoc exp, String JavaDoc numb, String JavaDoc name, String JavaDoc org)
13     throws javax.ejb.CreateException JavaDoc {
14
15
16     setExpirationDate(exp);
17     setNumber(numb);
18     setNameOnCard(name);
19     setCreditOrganization(org);
20         int id = seqLocal.getNextNumberInSequence("CreditCard");
21     setId(new Integer JavaDoc(id));
22     return null;
23     }
24
25     public void ejbPostCreate(Date JavaDoc exp, String JavaDoc numb, String JavaDoc name, String JavaDoc org) {
26     }
27
28     // relationship fields
29

30     public abstract CustomerLocal getCustomer( );
31     public abstract void setCustomer(CustomerLocal cust);
32
33     public abstract CreditCompanyLocal getCreditCompany( );
34     public abstract void setCreditCompany(CreditCompanyLocal cc); // persistent fields
35

36
37     public abstract Integer JavaDoc getId();
38     public abstract void setId(Integer JavaDoc id);
39     public abstract Date JavaDoc getExpirationDate();
40     public abstract void setExpirationDate(Date JavaDoc date);
41     public abstract String JavaDoc getNumber();
42     public abstract void setNumber(String JavaDoc number);
43     public abstract String JavaDoc getNameOnCard();
44     public abstract void setNameOnCard(String JavaDoc name);
45     public abstract String JavaDoc getCreditOrganization();
46     public abstract void setCreditOrganization(String JavaDoc org);
47
48     // standard call back methods
49

50     public void setEntityContext(EntityContext JavaDoc ec){
51     try {
52         InitialContext JavaDoc cntx = new InitialContext JavaDoc( );
53         SequenceSessionLocalHome seqHome =
54             (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome");
55         seqLocal = seqHome.create();
56     } catch(Exception JavaDoc e) {
57         throw new javax.ejb.EJBException JavaDoc(e);
58     }
59     }
60     public void unsetEntityContext(){}
61     public void ejbLoad(){}
62     public void ejbStore(){}
63     public void ejbActivate(){}
64     public void ejbPassivate(){}
65     public void ejbRemove() throws javax.ejb.RemoveException JavaDoc{}
66
67 }
68
Popular Tags