public void deleteTestDataAndCloseSession() {
session.clear();
if ( session.getTransaction().isActive() ) {
session.getTransaction().rollback();
}
Transaction transaction = session.beginTransaction();
Novel novel = (Novel) session.get( Novel.class, "novel-1" );
if ( novel != null ) {
session.delete( novel );
}
Animal animal = (Animal) session.get( Animal.class, "animal-1" );
if ( animal != null ) {
session.delete( animal );
}
animal = (Animal) session.get( Animal.class, "animal-2" );
if ( animal != null ) {
session.delete( animal );
}
Zoo zoo = (Zoo) session.get( Zoo.class, "zoo-1" );
if ( zoo != null ) {
session.delete( zoo );
}
Contributor contributor = (Contributor) session.get( Contributor.class, "contributor-1" );
if ( contributor != null ) {
session.delete( contributor );
}
contributor = (Contributor) session.get( Contributor.class, "contributor-2" );
if ( contributor != null ) {
session.delete( contributor );
}
Project project = (Project) session.get( Project.class, "project-1" );
if ( project != null ) {
session.delete( project );
}
project = (Project) session.get( Project.class, "project-2" );
if ( project != null ) {
session.delete( project );
}
project = (Project) session.get( Project.class, "project-3" );
if ( project != null ) {
session.delete( project );
}
ProjectGroup projectGroup = (ProjectGroup) session.get( ProjectGroup.class, "project-group-1" );
if ( projectGroup != null ) {
session.delete( projectGroup );
}
transaction.commit();
session.close();
}