1 package org.apache.ojb.ejb.pb; 2 3 17 18 import javax.ejb.SessionBean ; 19 import java.util.Collection ; 20 21 import org.apache.ojb.broker.PersistenceBroker; 22 import org.apache.ojb.broker.query.Criteria; 23 import org.apache.ojb.broker.query.Query; 24 import org.apache.ojb.broker.query.QueryByCriteria; 25 import org.apache.ojb.ejb.PersonVO; 26 27 56 public class PersonManagerPBBean extends PBBaseBeanImpl implements SessionBean 57 { 58 61 public PersonVO storePerson(PersonVO person) 62 { 63 return (PersonVO) this.storeObject(person); 64 } 65 66 69 public Collection storePersons(Collection persons) 70 { 71 return this.storeObjects(persons); 72 } 73 74 77 public void deletePerson(PersonVO person) 78 { 79 this.deleteObject(person); 80 } 81 82 85 public void deletePersons(Collection persons) 86 { 87 this.deleteObjects(persons); 88 } 89 90 93 public int countPersons() 94 { 95 return this.getCount(PersonVO.class); 96 } 97 98 101 public Collection getAllPersons() 102 { 103 return this.getAllObjects(PersonVO.class); 104 } 105 106 109 public Collection getPersons(String firstname, String lastname) 110 { 111 PersistenceBroker broker = getBroker(); 112 Criteria criteria = new Criteria(); 113 if (firstname != null) criteria.addEqualTo("firstname", firstname); 114 if (lastname != null) criteria.addEqualTo("firstname", lastname); 115 Query q = new QueryByCriteria(PersonVO.class); 116 Collection result = broker.getCollectionByQuery(q); 117 broker.close(); 118 return result; 119 } 120 } 121 | Popular Tags |