JPAGenerator (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.industry

## Class JPAGenerator

- java.lang.Object
- - tv.amwa.maj.industry.JPAGenerator

-     public class JPAGenerator
      extends Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Class<?>[]` | `abstractInterchangeable` List of abstract AAF classes that are part of the interchangeable object hierarchy, i.e.
    `static Class<?>[]` | `interchangeable` List of concrete AAF classes that are interchangeable as they extend `InterchangeObject`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JPAGenerator()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `generateORM(Collection<Class<? extends MediaEntity>> mediaClassList, String fileName)` Generate an object relational mapping Java Persistence API 2.0 configuration file (`orm.xml`) from the given collection of classes and store it in the given file.
    `static void` | `main(String[] args)`

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### interchangeable

          public static final Class<?>[] interchangeable

      List of concrete AAF classes that are interchangeable as they extend `InterchangeObject`.

    - #### abstractInterchangeable

          public static final Class<?>[] abstractInterchangeable

      List of abstract AAF classes that are part of the interchangeable object hierarchy, i.e. abstract and extending `InterchangeObject`.

  - ### Constructor Detail

    - #### JPAGenerator

          public JPAGenerator()

  - ### Method Detail

    - #### generateORM

          public static final boolean generateORM(Collection<Class<? extends MediaEntity>> mediaClassList,
                                                  String fileName)
                                           throws NullPointerException,
                                                  IllegalArgumentException

      Generate an object relational mapping Java Persistence API 2.0 configuration file (`orm.xml`) from the given collection of classes and store it in the given file. Any embeddable objects or other utility class mappings will be included in the mapping if they are required.

      The mapping file allows the given media entities to be persisted to a relational database using a JPA implementation, such as Open JPA or Hibernate. By using this method, a developer only needs to use one set of annotations to turn a class into both:

      - a media class that benefits from the facilities of this media engine;
      - a JPA persistent entity, also known as an EJB3 entity bean.

      Another benefit of using media annotations rather than JPA annotations is that this code base can be compiled in Java SE without the need for JPA libraries to be present.

      Parameters:
        `mediaClassList` - Collection of classes to create object relational mappings for.
        `fileName` - Name and path of the object relational mapping file to create.
      Returns:
        Was an object-relational mapping file generated successfully?
      Throws:
        `NullPointerException` - Cannot generate an object relational mapping if any of the input values or classes is `null`.
        `IllegalArgumentException` - One or more of the given classes is not annotated as a media class.

    - #### main

          public static final void main(String[] args)
                                 throws Exception

      Throws:
        `Exception`

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.