Table « Test « JPA Q&A





1. How to test if a table is empty, using Hibernate    stackoverflow.com

Using Hibernate, what is the most efficient way to determine if a table is empty or non-empty? In other words, does the table have 0, or more than 0 rows? I could ...

2. Best way to truncate all tables with hibernate?    stackoverflow.com

I would like to truncate all my database tables between one integration test to another. What is the best way to do this using hibernate? Currently I'm doing this:

public void cleanDatabase() {
 ...

3. Unit-Testing: Simple way to remove data from all tables?    forum.hibernate.org

I use simple delete from table name. You could recreate your tables as well when your db is not large enough. Problem is that during development you might want some tables to stay (configuration tables) and other to be cleaned. I do not think that you can do this manually. A delete cascade table definition (not in Hibernate but in the ...