Adding @Autowired to your personDao should solve this problem. You'll also
need a @Test annotation on your test method. I've updated the tutorial to
reflect this.

Matt

On Sat, Nov 21, 2009 at 9:36 AM, QuanNH <huu2...@gmail.com> wrote:

>
> hi
>
> i follow this tut http://appfuse.org/display/APF/Using+Hibernate and get
> error when Run the DAO Test:
>
> Running com.mycompany.dao.PersonDaoTest
> Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
>
> testFindPersonByLastName(com.mycompany.dao.PersonDaoTest)  Time elapsed:
> 0.356 sec  <<< ERROR!
> java.lang.NullPointerException
>        at
>
> com.mycompany.dao.PersonDaoTest.testFindPersonByLastName(PersonDaoTest.java:23)
>  line 23: List<Person> people = personDao.findByLastName("Raible");
>
> Testcase: testAddAndRemovePerson(com.mycompany.dao.PersonDaoTest):
> Caused an ERROR
> null
> java.lang.NullPointerException
>        at
>
> com.mycompany.dao.PersonDaoTest.testAddAndRemovePerson(PersonDaoTest.java:32)
>  line 32: person = personDao.save(person);
>
> sample_data has push to database.
>
> i dont know how to fix this error
>
> please help me
>
> Thanks
>
> --
> View this message in context:
> http://n4.nabble.com/error-NullPointerException-when-using-hibernate-tp680382p680382.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net
> For additional commands, e-mail: users-h...@appfuse.dev.java.net
>
>

Reply via email to