01: package org.objectweb.jonas.jtests.beans.ejbql;
02:
03: import javax.ejb.CreateException;
04: import javax.ejb.EntityContext;
05: import javax.ejb.RemoveException;
06: import javax.naming.InitialContext;
07:
08: public abstract class CreditCompanyBean implements javax.ejb.EntityBean {
09:
10: private SequenceSessionLocal seqLocal = null;
11:
12: public Integer ejbCreate(String name) throws CreateException {
13: int id = seqLocal.getNextNumberInSequence("CreditCompany");
14: setId(new Integer(id));
15: setName(name);
16: setNum(id);
17: return null;
18: }
19:
20: public void ejbPostCreate(String name) {
21: }
22:
23: // persistent fields
24:
25: public abstract void setId(Integer id);
26:
27: public abstract Integer getId();
28:
29: public abstract void setName(String name);
30:
31: public abstract String getName();
32:
33: public abstract void setNum(int num);
34:
35: public abstract int getNum();
36:
37: // relationship fields
38:
39: public abstract AddressLocal getAddress();
40:
41: public abstract void setAddress(AddressLocal cust);
42:
43: // standard call back methods
44:
45: public void setEntityContext(EntityContext ec) {
46: try {
47: InitialContext cntx = new InitialContext();
48: SequenceSessionLocalHome seqHome = (SequenceSessionLocalHome) cntx
49: .lookup("java:comp/env/ejb/SequenceSessionLocalHome");
50: seqLocal = seqHome.create();
51: } catch (Exception e) {
52: throw new javax.ejb.EJBException(e);
53: }
54: }
55:
56: public void unsetEntityContext() {
57: }
58:
59: public void ejbLoad() {
60: }
61:
62: public void ejbStore() {
63: }
64:
65: public void ejbActivate() {
66: }
67:
68: public void ejbPassivate() {
69: }
70:
71: public void ejbRemove() throws RemoveException {
72: }
73:
74: }
|