org.unitils.orm.jpa
Class JpaUnitils

java.lang.Object
  extended by org.unitils.orm.jpa.JpaUnitils

public class JpaUnitils
extends Object

Utility facade for handling JPA related stuff such as asserting whether the mappings correspond to the actual structure of the database.

Author:
Filip Neven, Tim Ducheyne

Constructor Summary
JpaUnitils()
           
 
Method Summary
static void assertMappingWithDatabaseConsistent()
          Checks if the mapping of the JPA entities with the database is still correct for the configurations that are loaded for the current test.
static void flushDatabaseUpdates()
          Flushes all pending entity manager updates to the database.
static javax.persistence.EntityManager getEntityManager()
           
static javax.persistence.EntityManagerFactory getEntityManagerFactory()
           
static void injectEntityManagerInto(Object target)
          For the given target object, injects the active, transactional EntityManager into fields or methods annotated with javax.persistence.PersistenceContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JpaUnitils

public JpaUnitils()
Method Detail

assertMappingWithDatabaseConsistent

public static void assertMappingWithDatabaseConsistent()
Checks if the mapping of the JPA entities with the database is still correct for the configurations that are loaded for the current test.


flushDatabaseUpdates

public static void flushDatabaseUpdates()
Flushes all pending entity manager updates to the database. This method is useful when the effect of updates needs to be checked directly on the database, without passing through the currently active EntityManager


injectEntityManagerInto

public static void injectEntityManagerInto(Object target)
For the given target object, injects the active, transactional EntityManager into fields or methods annotated with javax.persistence.PersistenceContext

Parameters:
target -

getEntityManagerFactory

public static javax.persistence.EntityManagerFactory getEntityManagerFactory()
Returns:
The EntityManagerFactory configured for the current test object (spring or using the JpaEntityManagerFactory annotation.

getEntityManager

public static javax.persistence.EntityManager getEntityManager()
Returns:
An EntityManager associated with the current transaction. This method returns the same EntityManager during the course of a transaction.


Copyright © 2011. All Rights Reserved.