1 package org.objectweb.jonas.jtests.beans.ejbql; 2 3 import java.util.ArrayList ; 4 import java.util.Collection ; 5 import java.util.Iterator ; 6 7 import javax.ejb.EntityContext ; 8 import javax.ejb.FinderException ; 9 import javax.naming.InitialContext ; 10 11 12 public abstract class AddressBean implements javax.ejb.EntityBean { 13 14 private SequenceSessionLocalHome seqHome = null; 15 private SequenceSessionLocal seqLocal = null; 16 17 public Integer ejbCreateAddress(String street, String city, String state, String zip ) 18 throws javax.ejb.CreateException { 19 setStreet(street); 20 setCity(city); 21 setState(state); 22 setZip(zip); 23 int id = seqLocal.getNextNumberInSequence("Address"); 24 setId(new Integer (id)); 25 return null; 26 } 27 28 public void ejbPostCreateAddress (String street, String city,String state, String zip){ 29 } 30 31 public abstract Integer getId(); 33 public abstract void setId(Integer id); 34 public abstract String getStreet(); 35 public abstract void setStreet(String street); 36 public abstract String getCity(); 37 public abstract void setCity(String city); 38 public abstract String getState(); 39 public abstract void setState(String state); 40 public abstract String getZip(); 41 public abstract void setZip(String zip); 42 43 public abstract long ejbSelectCountOfCities() throws FinderException ; 45 public abstract long ejbSelectCountOfDistinctCities() throws FinderException ; 46 public abstract Collection ejbSelectCities() throws FinderException ; 47 public abstract Collection ejbSelectCreditCompanies() throws FinderException ; 48 public abstract Collection ejbSelectCreditCompanyNames() throws FinderException ; 49 public abstract Collection ejbSelectCreditCompanyIds() throws FinderException ; 50 public abstract Collection ejbSelectCreditCompanyNums() throws FinderException ; 51 52 public long ejbHomeGetCountOfCities() throws FinderException { 54 return this.ejbSelectCountOfCities(); 55 } 56 public long ejbHomeGetCountOfDistinctCities() throws FinderException { 57 return this.ejbSelectCountOfDistinctCities(); 58 } 59 public Collection ejbHomeGetAllCities() throws FinderException { 60 return this.ejbSelectCities(); 61 } 62 public Collection ejbHomeGetAllCreditCompanies() throws FinderException { 63 Collection ccs = this.ejbSelectCreditCompanies(); 64 Iterator iCCs = ccs.iterator(); 65 ArrayList ccsId = new ArrayList (); 66 while (iCCs.hasNext()) { 67 CreditCompanyLocal cclb = (CreditCompanyLocal) iCCs.next(); 68 if (cclb != null) { 69 ccsId.add(cclb.getId()); 70 } 71 } 72 return ccsId; 73 } 74 public Collection ejbHomeGetAllCreditCompanyNames() throws FinderException { 75 return this.ejbSelectCreditCompanyNames(); 76 } 77 public Collection ejbHomeGetAllCreditCompanyIds() throws FinderException { 78 return this.ejbSelectCreditCompanyIds(); 79 } 80 public Collection ejbHomeGetAllCreditCompanyNums() throws FinderException { 81 return this.ejbSelectCreditCompanyNums(); 82 } 83 84 public void setEntityContext(EntityContext ec){ 86 try { 87 InitialContext cntx = new InitialContext ( ); 88 SequenceSessionLocalHome seqHome = 89 (SequenceSessionLocalHome)cntx.lookup("java:comp/env/ejb/SequenceSessionLocalHome"); 90 seqLocal = seqHome.create(); 91 } catch(Exception e) { 92 throw new javax.ejb.EJBException (e); 93 } 94 95 } 96 97 public void unsetEntityContext(){} 98 public void ejbLoad(){} 99 public void ejbStore(){} 100 public void ejbActivate(){} 101 public void ejbPassivate(){} 102 public void ejbRemove() throws javax.ejb.RemoveException {} 103 104 } 105 | Popular Tags |