| At line 168 changed 1 line. |
| To start, create a PersonDaoTest.java class in the test/dao/**/persistence directory. This class should extend [BaseDaoTestCase|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/persistence/BaseDaoTestCase.java.html], which already exists in this package. This parent class is used to load [Spring's|http://www.springframework.org] ApplicationContext (since Spring binds the layers together), and for automatically loading a .properties file (ResourceBundle) that has the same name as your *Test.class. In this example, if you put a PersonDaoTest.properties file in the same directory as PersonDaoTest.java, this file's properties will be available via an "rb" variable. |
| To start, create a PersonDaoTest.java class in the test/dao/**/dao directory. This class should extend [BaseDaoTestCase|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html], which already exists in this package. This parent class is used to load [Spring's|http://www.springframework.org] ApplicationContext (since Spring binds the layers together), and for automatically loading a .properties file (ResourceBundle) that has the same name as your *Test.class. In this example, if you put a PersonDaoTest.properties file in the same directory as PersonDaoTest.java, this file's properties will be available via an "rb" variable. |
| At line 174 changed 1 line. |
| package org.appfuse.persistence; |
| package org.appfuse.dao; |
| At line 203 changed 1 line. |
| The code you see above is what we need for a basic JUnit test that initializes and destroys our PersonDao. The "ctx" object is a reference to Spring's ApplicationContext, which is initialized in a static block of the [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/persistence/BaseDaoTestCase.java.html] class. |
| The code you see above is what we need for a basic JUnit test that initializes and destroys our PersonDao. The "ctx" object is a reference to Spring's ApplicationContext, which is initialized in a static block of the [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html] class. |
| At line 290 changed 1 line. |
| First off, create a PersonDao.java interface in the src/dao/**/persistence directory and specify the basic CRUD methods for any implementation classes. ''I've eliminated the JavaDocs in the class below for display purposes.'' |
| First off, create a PersonDao.java interface in the src/dao/**/dao directory and specify the basic CRUD methods for any implementation classes. ''I've eliminated the JavaDocs in the class below for display purposes.'' |
| At line 294 changed 1 line. |
| package org.appfuse.persistence; |
| package org.appfuse.dao; |
| At line 316 changed 1 line. |
| Let's start by creating a PersonDaoHibernate class that implements the methods in PersonDao and uses Hibernate to get/save/delete the Person object. To do this, create a new class in src/dao/**/persistence/hibernate and name it PersonDAOHibernate.java. It should extend [BaseDaoHibernate|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/persistence/BaseDAOHibernate.java.html] and implement PersonDAO. ''Javadocs eliminated for brevity.'' |
| Let's start by creating a PersonDaoHibernate class that implements the methods in PersonDao and uses Hibernate to get/save/delete the Person object. To do this, create a new class in src/dao/**/dao/hibernate and name it PersonDAOHibernate.java. It should extend [BaseDaoHibernate|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDAOHibernate.java.html] and implement PersonDAO. ''Javadocs eliminated for brevity.'' |
| At line 320 changed 1 line. |
| package org.appfuse.persistence.hibernate; |
| package org.appfuse.dao.hibernate; |
| At line 326 changed 1 line. |
| import org.appfuse.persistence.PersonDao; |
| import org.appfuse.dao.PersonDao; |
| At line 360 changed 11 lines. |
| Example example = Example.create(person) |
| .excludeZeroes() //exclude zero valued properties |
| .ignoreCase(); //perform case insensitive string comparisons |
| try { |
| return getSession().createCriteria(Person.class) |
| .add(example) |
| .list(); |
| } catch (Exception e) { |
| throw new DAOException(e); |
| } |
| return new ArrayList(); |
| Example example = Example.create(person) |
| .excludeZeroes() //exclude zero valued properties |
| .ignoreCase(); //perform case insensitive string comparisons |
| try { |
| return getSession().createCriteria(Person.class) |
| .add(example) |
| .list(); |
| } catch (Exception e) { |
| throw new DAOException(e); |
| } |
| return new ArrayList(); |
| At line 378 changed 1 line. |
| First, we need to tell Spring where the Hibernate mapping file is located. To do this, open src/dao/**/persistence/hibernate/applicationContext-hibernate.xml and add {{Person.hbm.xml}} to the following code block. |
| First, we need to tell Spring where the Hibernate mapping file is located. To do this, open src/dao/**/dao/hibernate/applicationContext-hibernate.xml and add {{Person.hbm.xml}} to the following code block. |
| At line 398 changed 1 line. |
| <bean id="personDao" class="org.appfuse.persistence.hibernate.PersonDaoHibernate"> |
| <bean id="personDao" class="org.appfuse.dao.hibernate.PersonDaoHibernate"> |