The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

namor (2) [Avatar] Offline

I'm developing a little stand-alone app where i'd like to use hibernate - and of course test it smilie

Unfortunately, I'm not very familiar with hibernate and junit/dbunit - so I've some questions:

1) A friend gave me the hint to use the Hibernate-Generic-DAO approach which speeds me up writting my own DAO's. As I want to use the test-infrastructure proposed at figure 18.1, I am actual stumbled with the first abstract class 'AbstractJpaTestCase'. It uses the EntityManager to access the database - something I don't do within my DAO's because all my DAO's extend the GenericDAO - and this uses the hibernate session object to access the database. Those session-objects are retrieved via a helper-class which initializes a sessionfactory-object. So what is the best way to test my DAO-classes? Should I replace the EntityManager variable with an instance of the DAO which is beeing tested?

2) Connection-Object: As the DBUnitConnection is created via a Connection-object, where do I obtain such an object using Hibernate instead of DriverManager? I only figured out the session.connection() - method - but it's marked as depreciated .... so this might not work in further releases ?!

3) JUnit4ClassRunner: in the source class 'AbstractJpaDbUnitELTemplateTestCaseJUnit44' , the inner class 'DataSetsTemplateRunner' extends the JUnit4ClassRunner ... again this is marked as deprecated. Is there an alternative solution?

Hope my questions are somehow understandable and not too annoying smilie

kind regards,