At line 124 changed 1 line. |
Open test/ejb/**/persistence/PersonDaoTest.java and add a ''testGetPersons'' method: |
Open test/dao/**/persistence/PersonDaoTest.java and add a ''testGetPersons'' method: |
At line 135 changed 1 line. |
The reason I'm passing in a person object to the ''getPersons'' method is to allow for filtering (based on values in person) in the future. |
The reason I'm passing in a person object to the ''getPersons'' method is to allow for filtering (based on values in person) in the future. |
At line 137 changed 1 line. |
Now open test/web/**/service/PersonManagerTest.java and add a ''testGetPersons'' method: |
Now open test/service/**/service/PersonManagerTest.java and add a ''testGetPersons'' method: |
At line 151 changed 1 line. |
First, let's modify our interfaces to include a ''getPersons'' method. Open src/ejb/**/persistence/PersonDao.java and add the following: |
First, let's modify our interfaces to include a ''getPersons'' method. Open src/dao/**/persistence/PersonDao.java and add the following: |
At line 160 changed 1 line. |
Then, open src/web/**/service/PersonManager.java and add a similar method: |
Then, open src/service/**/service/PersonManager.java and add a similar method: |
At line 167 changed 1 line. |
Now we need to add the implementation (a.k.a. "the meat") for these methods into our DAO and Manager implementations. Open src/ejb/**/persistence/PersonDaoHibernate.java and add the following method: |
Now we need to add the implementation (a.k.a. "the meat") for these methods into our DAO and Manager implementations. Open src/dao/**/persistence/PersonDaoHibernate.java and add the following method: |
At line 174 changed 1 line. |
* @see org.appfuse.persistence.PersonDao#getPersons(org.appfuse.persistence.Person) |
* @see org.appfuse.persistence.PersonDao#getPersons(org.appfuse.model.Person) |
At line 177 changed 12 lines. |
List list = null; |
|
try { |
list = |
ses.createQuery("from p in class " + Person.class + |
" order by upper(p.firstName)").list(); |
} catch (Exception e) { |
e.printStackTrace(); |
throw new DAOException(e); |
} |
|
return list; |
return getHibernateTemplate().find("from Person p order by upper(p.firstName)"); |
At line 194 changed 1 line. |
Also, add a ''getPersons'' method to src/web/**/service/PersonManagerImpl.java: |
Also, add a ''getPersons'' method to src/service/**/service/PersonManagerImpl.java: |
At line 202 changed 3 lines. |
if (person == null) { |
person = new Person(); |
} |
Person person = (Person) convert(obj); |
At line 206 changed 20 lines. |
personForm = (PersonForm) obj; |
|
if (personForm == null) { |
personForm = new PersonForm(); |
} |
|
// copy search parameters to person |
BeanUtils.copyProperties(person, personForm); |
|
List persons = dao.getPersons(person); |
|
// loop through the list and convert all objects to forms |
for (int i = 0; i < persons.size(); i++) { |
Person p = (Person) persons.get(i); |
PersonForm pForm = new PersonForm(); |
BeanUtils.copyProperties(pForm, p); |
persons.set(i, pForm); |
} |
|
return persons; |
return dao.getPersons(person); |
At line 231 changed 2 lines. |
* __ant test-ejb -Dtestcase=PersonDao__ |
* __ant test-web -Dtestcase=PersonManager__ |
* __ant test-dao -Dtestcase=PersonDao__ |
* __ant test-service -Dtestcase=PersonManager__ |
At line 254 changed 1 line. |
This class will not compile until you add the PERSON_LIST variable to the src/common/**/common/Constants.java file. |
This class will not compile until you add the PERSON_LIST variable to the src/dao/**/Constants.java file. |