Class JpaGenericLightObjectTest<T extends ILightObject>

java.lang.Object
be.gaudry.dao.jpa.test.JpaGenericLightObjectTest<T>
Type Parameters:
T -
Direct Known Subclasses:
JpaLightObjectTest, JpaPersonExtTest, JpaPersonTest

public abstract class JpaGenericLightObjectTest<T extends ILightObject> extends Object
Since:
1.0 Oct 6, 2010, 1.0
Version:
%I%, %G%
Author:
Steph GAUDRY
  • Field Details

    • em

      protected static javax.persistence.EntityManager em
    • tx

      protected javax.persistence.EntityTransaction tx
    • MSGLINE

      protected String MSGLINE
    • tableName

      protected String tableName
      Name of the table for the T class, used into native SQL. Default value is class simple name (like for the JPQL queries).
  • Constructor Details

    • JpaGenericLightObjectTest

      public JpaGenericLightObjectTest(Class<T> clazz)
  • Method Details

    • getDataSet

      protected abstract org.dbunit.dataset.IDataSet getDataSet() throws Exception
      Throws:
      Exception
    • getEntityManagerName

      protected abstract String getEntityManagerName()
    • getCheckedItemDisplay

      protected abstract String getCheckedItemDisplay()
    • getCheckedItemId

      protected abstract int getCheckedItemId()
    • createObject

      protected abstract T createObject(String display)
    • closeAll

      public static void closeAll() throws SQLException
      Throws:
      SQLException
    • closeEntityManager

      public static void closeEntityManager()
    • resetEntityManager

      public final void resetEntityManager() throws Exception
      Closes and creates a new EntityManager to detach objects from the context
      Throws:
      Exception
    • initTransaction

      public final void initTransaction()
    • cleanDB

      public final void cleanDB() throws Exception
      Cleans the database and restore beginning data to start on a well known state
      Throws:
      Exception
    • createLightObject

      public final void createLightObject() throws Exception
      Tests quickly the EntityManager.persist(Object) method by inserting a new AbstractLightObject into the database.
      Throws:
      Exception
    • loadLightObjectById

      public final void loadLightObjectById() throws Exception
      Tests the loading by id of a AbstractLightObject injected into the database.
      Throws:
      Exception
    • loadLightObjectByDisplay

      public final void loadLightObjectByDisplay() throws Exception
      Tests the loading by id of a AbstractLightObject injected into the database.
      Throws:
      Exception
    • addAndRemoveLightObjects

      public final void addAndRemoveLightObjects() throws Exception
      Tests more deeply the EntityManager.persist(Object) method by inserting a new AbstractLightObject into the database. Tests also the EntityManager.remove(Object) method.
      Throws:
      Exception
    • modifyLightObject

      public final void modifyLightObject() throws Exception
      Throws:
      Exception
    • crossModification

      public final void crossModification() throws Exception
      Load twice a same DB object into 2 Java Objects, modifies one, checks 2nd has been updated, and load a third Java Object to check if the modifications has been persisted
      Throws:
      Exception