[ 
https://issues.apache.org/jira/browse/OPENJPA-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557843#action_12557843
 ] 

Pinaki Poddar commented on OPENJPA-147:
---------------------------------------

Excellent!

But something I am still missing once I changed to new @ManagedInterface

Here is an Interface:
===================================================
package jira147;

import org.apache.openjpa.persistence.ManagedInterface;

@ManagedInterface
public interface IPerson {
        public String getName();
        public void setName(String name);
}
=====================================================
Here is a test methood

        public void testNewInstance() {
                EntityManager em = emf.createEntityManager();
                OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
                Object ipc = oem.createInstance(IPerson.class);
                oem.getTransaction().begin();
                oem.persist(ipc);
                oem.getTransaction().commit();
        }
=====================================================
Here is a persistence unit

<persistence-unit name="test">
        <class>jira147.IPerson</class>
        <properties>
            <property name="openjpa.ConnectionDriverName" 
value="com.mysql.jdbc.Driver"/>
            <property name="openjpa.ConnectionURL" 
value="jdbc:mysql://localhost/openjpa"/>
        </properties>
   </persistence-unit>
====================================================
Here is the console
Using OpenJPA 420667:610924
62  test  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.1.0-SNAPSHOT
=======================================================
Here is the Stack Trace

java.lang.IllegalArgumentException: No registered metadata for type "interface 
jira147.IPerson".
        at org.apache.openjpa.enhance.PCRegistry.getMeta(PCRegistry.java:255)
        at 
org.apache.openjpa.enhance.PCRegistry.newInstance(PCRegistry.java:111)
        at 
org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4167)
        at 
org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1358)
        at 
org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1068)
        at jira147.TestInterface.testNewInstance(TestInterface.java:22)
        

> <T> T OpenJPAEntityManager.createInstance(Class<T> cls) fails when T is 
> interface
> ---------------------------------------------------------------------------------
>
>                 Key: OPENJPA-147
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-147
>             Project: OpenJPA
>          Issue Type: New Feature
>          Components: jpa
>            Reporter: Pinaki Poddar
>             Fix For: 1.1.0
>
>         Attachments: iface.trace.1.txt, iface.trace.2.txt, iface.trace.3.txt, 
> iface.trace.4.txt, IPerson.java, TestInterface.java
>
>
> 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. 
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to