Database « Test « JPA Q&A





1. Clearing Entire Database (for unit testing with Hibernate)    stackoverflow.com

My unit tests use Hibernate to connect to an in-memory HSQLDB database. I was hoping there would be a way to clear and recreate the database (the entire database including ...

2. How should I reset a JPA-controlled database before every test?    stackoverflow.com

Is there a best-practice pattern for completely resetting a database to a freshly-paved schema with JPA before a unit test? I have been using a testing persistence unit with hbml2ddl.auto=create-or-drop and ...

3. Using Stripersist with a test database    stackoverflow.com

I am trying to write comprehensive unit and integration tests for my project, but the integration database has a different connection string that the main database. I have loaded the ...

4. Unit testing with Hibernate without a running database    coderanch.com

I try to write as many tests as possible without hitting the database. For example, your persistent classes will often have many helper methods, such as methods to ensure bidirectional associations are setup correctly. These don't need any database and are testable as with any normal POJO. Once you start hitting the db, many tests can be written by starting a ...

5. Problems with db when doing testing    forum.hibernate.org

Hello, i'm new in hibernate. I'm doing some tests using testng. I got a problem because the information is created in the db, and it may not happened. I use: @BeforeClass public void beforeClass() { AnnotationConfiguration configuration = new AnnotationConfiguration(); ... sessionFactory = configuration.buildSessionFactory(); } @BeforeMethod public void beforeTest() { session = sessionFactory.openSession(); transaction = session.beginTransaction(); } @AfterMethod public void afterTest() ...

6. Testing without a Database?    forum.hibernate.org

Hibernate version: 2.1 ? Hello, I'm new to setting up and configuring Hibernate myself, but have been developing with it for about a year. We are using hibernate 2.1 currently and we have a small development team that works remotely and may or may not have access to the secured network where our deployment / test database resides. Is there a ...

8. How to test if username and password to database are correct    forum.hibernate.org

Hello, how to test if username and password to database are correct (and generally, connection settings) ? I use this code (and I also use C3P0 connection pooler): Code: Session s = getSessionFactory().getCurrentSession(); s.beginTransaction(); s.connection().createStatement(); s.getTransaction().commit(); When no exception happened, username and password are correct. ...

9. DB Scripts for junit tests in hibernate    forum.hibernate.org