OpenJPA
  1. OpenJPA
  2. OPENJPA-147

<T> T OpenJPAEntityManager.createInstance(Class<T> cls) fails when T is interface

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1.0
    • Component/s: jpa
    • Labels:
      None

      Description

      According to JavaDoc, OpenJPAEntityManager.createInstance() method
      public <T> T createInstance(Class<T> cls);
      behaves as follows:

      "Create a new instance of type <code>cls</code>. If <code>cls</code> is
      an interface or an abstract class whose abstract methods follow the
      JavaBeans convention, this method will create a concrete implementation
      according to the metadata that defines the class"

      The method fails when T is an interface. The failure may be due to incorrect user configuration, however, further
      information on this extension method is not available in OpenJPA documentation.

      Firstly, how to specify metadata for a interface that has bean-style methods?
      Possibilities are:
      a) Annotating the Java interface definition with @Entity
      b) Specifying in <class>org.acme.IPerson</class> in persistence.xml

      Either of the above fails. a) fails at parsing b) fails with "no metadata"

      There may be a correct but undocumented way of specifying a managed interface. If that is the case, then this JIRA report should be treated as a documentation bug.

      1. iface.trace.1.txt
        10 kB
        Pinaki Poddar
      2. iface.trace.2.txt
        8 kB
        Pinaki Poddar
      3. iface.trace.3.txt
        73 kB
        Pinaki Poddar
      4. iface.trace.4.txt
        10 kB
        Pinaki Poddar
      5. IPerson.java
        0.2 kB
        Pinaki Poddar
      6. TestInterface.java
        0.7 kB
        Pinaki Poddar

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Pinaki Poddar
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development