Package edu.wisc.game.sql

## Class Main

- java.lang.Object
- - edu.wisc.game.sql.Main

-     public class Main
      extends Object

  An object that is responsible for getting EntityManager object(s) for the application. Normally, an app would have just 1 instance of Main (Main.oneMain), because we work with just 1 database. Only applications that work with 2 (or more) databases, e.g. copying data between databases, would need additional instances of Main.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static String` | `persistenceUnitName` | This name will be used to configure the EntityManagerFactory based on the corresponding name in the META-INF/persistence.xml file

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Main​(MainConfig _config)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `javax.persistence.EntityManager` | `doGetEM()` |
    `javax.persistence.EntityManager` | `doGetNewEM()` |
    `void` | `doPersistObjects​(Object... v)` |
    `<T> void` | `doSaveObject​(T o)` |
    `static javax.persistence.EntityManager` | `getEM()` | Creates a new EntityManager from the EntityManagerFactory.
    `static int` | `getMyPid()` | Finds the process id of the UNIX process for this application.
    `static javax.persistence.EntityManager` | `getNewEM()` |
    `static void` | `memory()` | Reports memory use
    `static void` | `memory​(String title)` | Reports memory use
    `static String` | `memoryInfo​(String title, boolean doGc)` |
    `static void` | `persistObjects​(Object... v)` | See also https://download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf, which says (in "3.2.2 Persisting an Entity Instance"): If X is a new entity, it becomes managed.
    `static <T> void` | `saveObject​(T o)` |
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### persistenceUnitName

          public static final String persistenceUnitName

      This name will be used to configure the EntityManagerFactory based on the corresponding name in the META-INF/persistence.xml file
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Main

          public Main​(MainConfig _config)

  - ### Method Detail

    - #### getMyPid

          public static int getMyPid()

      Finds the process id of the UNIX process for this application. FIXME: This obviously is non-portable outside of UNIX.
      Returns:
        PID, or -1 on failure

    - #### getEM

          public static javax.persistence.EntityManager getEM()

      Creates a new EntityManager from the EntityManagerFactory.

    - #### doGetEM

          public javax.persistence.EntityManager doGetEM()

    - #### getNewEM

          public static javax.persistence.EntityManager getNewEM()

    - #### doGetNewEM

          public javax.persistence.EntityManager doGetNewEM()

    - #### memory

          public static void memory()

      Reports memory use

    - #### memory

          public static void memory​(String title)

      Reports memory use

    - #### memoryInfo

          public static String memoryInfo​(String title,
                                          boolean doGc)

    - #### persistObjects

          public static void persistObjects​(Object... v)

      See also https://download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf, which says (in "3.2.2 Persisting an Entity Instance"):
      - If X is a new entity, it becomes managed. The entity X will be entered into the database at or before transaction commit or as a result of the flush operation.
      - If X is a preexisting managed entity, it is ignored by the persist operation (...)
      - If X is a detached object, the EntityExistsException may be thrown when the persist operation is invoked, or the EntityExistsException or another PersistenceException may be thrown at flush or commit time

    - #### doPersistObjects

          public void doPersistObjects​(Object... v)

    - #### saveObject

          public static <T> void saveObject​(T o)

      Parameters:
        `o` - a detached object

    - #### doSaveObject

          public <T> void doSaveObject​(T o)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`