You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Gopi <go...@gmail.com> on 2009/10/26 22:02:45 UTC

Problems with Interfaces

Hi,

I am new to JPA and OpenJPA. I am trying to work with interfaces in JPA and
I am getting some exceptions. Can someone please help me out.

Summary of the problem
---------------------------

I have an interface called Endpoint and an implementation of that called
EndpointObject. When I commit the EndpointObject to a database, I get the
exception that the 'relation endpoint does not exist'. I see a table called
'endpointobject' that is created in the database but not 'endpoint'. I have
provided all my code and all other details below.

1. Endpoint.java

import javax.persistence.Basic;
import javax.persistence.Id;

import org.apache.openjpa.persistence.ManagedInterface;

@ManagedInterface
public interface Endpoint {

	@Id
	public long getId();

	@Basic
	public String getSite_name();
	public void setSite_name(String siteName);

}

2. EndpointObject.java

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

@Entity
public class EndpointObject implements Endpoint {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;
	
	@Basic
	private String site_name;

	public long getId() {
		return id;
	}

	public String getSite_name() {
		return site_name;
	}

	public void setSite_name(String siteName) {
		site_name = siteName;
	}

	public EndpointObject() {

	}
}

3. Main.java.

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;

import org.apache.openjpa.jdbc.kernel.TableJDBCSeq;
import org.apache.openjpa.meta.ClassMetaData;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.openjpa.persistence.OpenJPAPersistence;

public class Main {

	public static void main(String[] args) {

		EntityManagerFactory factory =
Persistence.createEntityManagerFactory("TestJPA1");
		EntityManager em = factory.createEntityManager();
		OpenJPAEntityManager em1 = OpenJPAPersistence.cast(em);

		try {
			Class c = Class.forName("Endpoint");

			OpenJPAEntityManagerFactory factory1 = em1.getEntityManagerFactory();
			OpenJPAEntityManagerFactorySPI spi = (OpenJPAEntityManagerFactorySPI)
factory1;
			spi.getConfiguration().getMetaDataRepositoryInstance().register(c);
			ClassMetaData cmd =
spi.getConfiguration().getMetaDataRepositoryInstance().addMetaData(c,
			                ClassMetaData.ACCESS_PROPERTY);

			cmd.setManagedInterface(true);
			String[] str = new String[2];
			str[0] = "-action";
			str[1] = "add";
			TableJDBCSeq.main(str);
			Endpoint ep = (Endpoint) em1.createInstance(c);
			ep.setSite_name("site_name1");

			em1.getTransaction().begin();
			em1.persist(ep);
			em1.getTransaction().commit();

			Query q = em1.createQuery("SELECT a FROM Endpoint a");

			for (int i = 0; i < q.getResultList().size(); ++i) {
				Endpoint ep1 = (Endpoint) q.getResultList().get(i);
				System.out.println(ep1.getId() + " " + ep.getSite_name());
			}
			em1.close();
			factory1.close();
			em.close();
			factory.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

4. orm.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
</entity-mappings>


5. persistence.xml 

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="TestJPA1">
	   <provider> org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
        
        <class>EndpointObject</class>
        <properties>
            <property name="openjpa.ConnectionURL"
value="jdbc:postgresql://localhost:5432/datakoa"/>
            <property name="openjpa.ConnectionDriverName"
value="org.postgresql.Driver"/>
            <property name="openjpa.ConnectionUserName" value="gopi"/>
            <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
            <property name="openjpa.ConnectionPassword" value="gopi"/>
        </properties>
        
    </persistence-unit>
</persistence>

6. I am running this on a Mac OSX 10.5.8

7. JVM is 

java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-226)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-92, mixed mode)

8. Postgres jdbc driver version is postgresql-8.4-701.jdbc3.jar
-- 
View this message in context: http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3894934.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Problems with Interfaces

Posted by Pinaki Poddar <pp...@apache.org>.
> To be honest, I'm not entirely clear on how the 
> @ManagedInterface instance creation integrates with our enhancement
> processing. 

The implementation of a managed interface is generated at byte-code level
and enhanced (both at runtime).



-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3903451.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Problems with Interfaces

Posted by Kevin Sutter <kw...@gmail.com>.
It looks like this @ManagedInterface usage needs some work...  This code
snippet contains code that "should not be necessary" (according to other
referenced appends and common sense).  Directly messing with the
MetaDataRepository should not be a common user occurrence...  The code I am
referencing is like this...

            OpenJPAEntityManager em = OpenJPAPersistence.cast(normalEm);

>         OpenJPAEntityManagerFactory factory =
>  em.getEntityManagerFactory();
>         OpenJPAEntityManagerFactorySPI spi =
>  (OpenJPAEntityManagerFactorySPI)factory;
>
> spi.getConfiguration().getMetaDataRepositoryInstance().register(c);
>          ClassMetaData cmd =
>  spi.getConfiguration().getMetaDataRepositoryInstance().addMetaData(c,
> ClassMetaData.MODE_ALL);
>         cmd.setManagedInterface(true);


This is pretty ugly code and customer applications should not be directly
manipulating these structures.  If this is really required, then the
@ManagedInterface feature needs some re-work.  But, it also sounds like
without this code, things don't work either.  So, something is out of whack.

I did a quick search through the JIRAs and I did find this item [1].  Maybe
some of the problems are due to the move to JDK 6, but that should only be a
requirement for trunk (OpenJPA 2.0.x).  Other releases (1.0.x, 1.2.x, and
1.3.x) should not be affected by this JDK move.

I also just looked at our junit test suite [2] and it doesn't look like the
"ugly code" above is necessary.  Please reference our current set of tests
to see how your code matches up.  If you find areas of the documentation
that need updating, let us know.

Thanks,
Kevin

[1]  https://issues.apache.org/jira/browse/OPENJPA-1012
[2]  Look at org.apache.openjpa.persistence.managedinterface package in
openjpa-persistence-jdbc test suite

On Thu, Oct 29, 2009 at 11:30 AM, shriram <sh...@yahoo.com> wrote:

> Hello all.,
>
> I am trying to test managed interfaces.
>
> Getting the following exception, couldn't find any doc in the internet.
>
> Exception in thread "main" java.lang.IllegalArgumentException: Invalid
> access type "invalid code 31" for "com.ejb.entity.Drivable".
>        at
> org.apache.openjpa.meta.ClassMetaData.setAccessType(ClassMetaData.java:692)
>        at
> org.apache.openjpa.meta.AbstractMetaDataDefaults.populate(AbstractMetaDataDefaults.java:156)
>        at
> org.apache.openjpa.persistence.PersistenceMetaDataDefaults.populate(PersistenceMetaDataDefaults.java:257)
>        at
> org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.java:883)
>         at jpatesting.Main.main(Main.java:66)
>
> //**** Code *******//
>         EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("jpatestingPU");
>         EntityManager normalEm = emf.createEntityManager();
>         Class c =  Class.forName("com.ejb.entity.Drivable");
>         OpenJPAEntityManager em = OpenJPAPersistence.cast(normalEm);
>         OpenJPAEntityManagerFactory factory =
>  em.getEntityManagerFactory();
>         OpenJPAEntityManagerFactorySPI spi =
>  (OpenJPAEntityManagerFactorySPI)factory;
>
> spi.getConfiguration().getMetaDataRepositoryInstance().register(c);
>          ClassMetaData cmd =
>  spi.getConfiguration().getMetaDataRepositoryInstance().addMetaData(c,
> ClassMetaData.MODE_ALL);
>         cmd.setManagedInterface(true);
>        Drivable d1=(Drivable)em.createInstance(c);
>        System.out.println("Instance====>"+d1);
>        d1.setName("Ford Mushtang");
>        em.getTransaction().begin();
>        em.persist(d1);
>        em.getTransaction().commit();
>
>
>
>
> ________________________________
> From: Michael Dick <mi...@gmail.com>
> To: users@openjpa.apache.org
> Sent: Wed, October 28, 2009 5:17:59 PM
> Subject: Re: Problems with Interfaces
>
> Hi Gopi,
>
> The ManagedInterface annotation is intended to be used when you don't have
> a
> concrete class. Instead OpenJPA will generate one for you [1]. Having a
> concrete implementation might be contributing to your problem.
>
> That said, I think the specific error you're hitting is the result of not
> listing com.ejb.entity.FordMushtang in persistence.xml (along with
> com.ejb.entity.Drivable).
>
> If you provide a list of entity types those are the only ones that get
> enhanced. Basically you should list all the classes you plan on using.
>
> [1]
>
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_interfaces
>
> Hope this helps,
> -mike
>
> On Wed, Oct 28, 2009 at 9:15 AM, shriram <sh...@yahoo.com> wrote:
>
> > Kevin,
> >
> > I just tried this as an example.
> >
> > Can you please let me know if something wrong in my assumption.
> >
> > @ManagedInterface
> > interface Drivable
> >
> > class FordMushtang implements Drivable
> >
> > and my persistence.xml
> >
> >
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> >     <class>com.ejb.entity.Drivable</class>
> >
> > <properties>
> >      <property name="openjpa.RuntimeUnenhancedClasses"
> value="supported"/>
> >    </properties>
> >
> > I am getting an exception of
> >
> > <openjpa-2.0.0-M3-r422266:822833 nonfatal user error>
> > org.apache.openjpa.persistence.ArgumentException: Attempt to cast
> instance
> > "com.ejb.entity.FordMushtang[id=234234234]" to PersistenceCapable failed.
> >  Ensure that it has been enhanced.
> > FailedObject: com.ejb.entity.FordMushtang[id=234234234]
> >        at
> >
> org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4480)
> >        at
> > org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2505)
> >        at
> > org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2366)
> >        at
> >
> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1039)
> >        at
> >
> org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:696)
> >        at jpatesting.Main.persist(Main.java:85)
> >        at jpatesting.Main.main(Main.java:66)
> >
> >
> >
> >
> >
> > ________________________________
> > From: Kevin Sutter <kw...@gmail.com>
> > To: users@openjpa.apache.org
> > Sent: Wed, October 28, 2009 8:53:07 AM
> > Subject: Re: Problems with Interfaces
> >
> > Hi Gopi,
> >
> > On Mon, Oct 26, 2009 at 6:10 PM, Gopi <go...@gmail.com> wrote:
> >
> > >
> > > > o  The @ManagedInterface "instances" are created by the runtime when
> > you
> > > > call createInstance(c).  You should not be defining a separate
> @Entity
> > > > class.  This is like doubly defining your object model.
> > > >
> > > >
> > >
> > > Ok. I removed the @Entity from the class. So now in my persistence.xml,
> > > instead of <class>EndpointObject</class>, I now have
> > > <class>Endpoint</class>. Is this right?
> > >
> > > Yes, that's what I would expect.
> >
> >
> > >
> > > > o  To that end, your @GeneratedValue should be moved from your Entity
> > > > class
> > > > to your ManagedInterface interface.
> > > >
> > > >
> > > Ok. Done.
> > >
> > > Good.
> >
> >
> > > > o  And, it looks like you are doing a lot of extra processing with
> > > > registration with the MetaDataRepository and ClassMetaData.  You
> should
> > > > not
> > > > have to mess around with these data structures.  After creating the
> > > > instance
> > > > and persisting it, the OpenJPA runtime should take care of the
> > > > registration.
> > > >
> > > >
> > >
> > > The reason I am doing the extra processing is because, if I don't, I
> get
> > > the
> > > following error message. I found a solution to this in this forum at
> > >
> > >
> >
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
> > >
> > >  [java] java.lang.IllegalArgumentException: No metadata was found for
> > > managed interface Endpoint.
> > >     [java]     at
> > > org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
> > >     [java]     at
> > >
> > >
> >
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
> > >     [java]     at
> > >
> > >
> >
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
> > >     [java]     at Main.main(Main.java:36)
> > >
> > > So how else do I get rid of this error message?
> > >
> >
> > According to that post, this extra processing should not be necessary if
> > you
> > have included the ManagedInterface "entity" in the <class> element of
> > persistence.xml.  So, even with the changes you did above, you are still
> > getting this exception?
> >
> > From Pinaki's response...
> >     "The metadata registration and classloading done in your code for
> > managed interface *should* not be required if you specify the class name
> in
> > <class> clause of persistence.xml. But please report if that is not the
> > case."
> >
> >
> > >
> > > > o  One additional thought is how are you performing the enhancement
> > > > processing [2]?  To be honest, I'm not entirely clear on how the
> > > > @ManagedInterface instance creation integrates with our enhancement
> > > > processing.  Maybe another developer can shed some light on this
> > aspect.
> > > >
> > > >
> > >
> > > I am doing this by passing an arg to the jvm as follows in my build.xml
> > > file.
> > >
> > > <target name="Main">
> > >                <java classname="Main" failonerror="true" fork="yes">
> > >                        <jvmarg
> > >
> value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar"
> > />
> > >                        <classpath refid="TestJPA1.classpath" />
> > >                </java>
> > > </target>
> > >
> >
> > If you are only using @ManagedInterfaces and no other @Entities, then
> this
> > should not even be required.  Pinaki's other reply on this thread has
> > indicated that due to the generated byte-codes that we do for the
> > @ManagedInterface instance creation, all of the enhancement processing is
> > already done.  But, if you have other @Entities, then the use of the
> > -javaagent is an easy way to get your Entities enhanced.
> >
> > Kevin
> >
> >
> > > --
> > > View this message in context:
> > > http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> > > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> > >
> >
> >
> >
> >
> >
>
>
>
>
>

Re: Problems with Interfaces

Posted by shriram <sh...@yahoo.com>.
Hello all.,

I am trying to test managed interfaces.

Getting the following exception, couldn't find any doc in the internet.

Exception in thread "main" java.lang.IllegalArgumentException: Invalid access type "invalid code 31" for "com.ejb.entity.Drivable".
        at org.apache.openjpa.meta.ClassMetaData.setAccessType(ClassMetaData.java:692)
        at org.apache.openjpa.meta.AbstractMetaDataDefaults.populate(AbstractMetaDataDefaults.java:156)
        at org.apache.openjpa.persistence.PersistenceMetaDataDefaults.populate(PersistenceMetaDataDefaults.java:257)
        at org.apache.openjpa.meta.MetaDataRepository.addMetaData(MetaDataRepository.java:883)
        at jpatesting.Main.main(Main.java:66)

//**** Code *******//
         EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpatestingPU");
         EntityManager normalEm = emf.createEntityManager();
         Class c =  Class.forName("com.ejb.entity.Drivable");
         OpenJPAEntityManager em = OpenJPAPersistence.cast(normalEm);
         OpenJPAEntityManagerFactory factory =  em.getEntityManagerFactory();
         OpenJPAEntityManagerFactorySPI spi =  (OpenJPAEntityManagerFactorySPI)factory;
         spi.getConfiguration().getMetaDataRepositoryInstance().register(c);
         ClassMetaData cmd =  spi.getConfiguration().getMetaDataRepositoryInstance().addMetaData(c, ClassMetaData.MODE_ALL);
         cmd.setManagedInterface(true);
        Drivable d1=(Drivable)em.createInstance(c);
        System.out.println("Instance====>"+d1);
        d1.setName("Ford Mushtang");
        em.getTransaction().begin();
        em.persist(d1);
        em.getTransaction().commit();




________________________________
From: Michael Dick <mi...@gmail.com>
To: users@openjpa.apache.org
Sent: Wed, October 28, 2009 5:17:59 PM
Subject: Re: Problems with Interfaces

Hi Gopi,

The ManagedInterface annotation is intended to be used when you don't have a
concrete class. Instead OpenJPA will generate one for you [1]. Having a
concrete implementation might be contributing to your problem.

That said, I think the specific error you're hitting is the result of not
listing com.ejb.entity.FordMushtang in persistence.xml (along with
com.ejb.entity.Drivable).

If you provide a list of entity types those are the only ones that get
enhanced. Basically you should list all the classes you plan on using.

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_interfaces

Hope this helps,
-mike

On Wed, Oct 28, 2009 at 9:15 AM, shriram <sh...@yahoo.com> wrote:

> Kevin,
>
> I just tried this as an example.
>
> Can you please let me know if something wrong in my assumption.
>
> @ManagedInterface
> interface Drivable
>
> class FordMushtang implements Drivable
>
> and my persistence.xml
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>     <class>com.ejb.entity.Drivable</class>
>
> <properties>
>      <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
>    </properties>
>
> I am getting an exception of
>
> <openjpa-2.0.0-M3-r422266:822833 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance
> "com.ejb.entity.FordMushtang[id=234234234]" to PersistenceCapable failed.
>  Ensure that it has been enhanced.
> FailedObject: com.ejb.entity.FordMushtang[id=234234234]
>        at
> org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4480)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2505)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2366)
>        at
> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1039)
>        at
> org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:696)
>        at jpatesting.Main.persist(Main.java:85)
>        at jpatesting.Main.main(Main.java:66)
>
>
>
>
>
> ________________________________
> From: Kevin Sutter <kw...@gmail.com>
> To: users@openjpa.apache.org
> Sent: Wed, October 28, 2009 8:53:07 AM
> Subject: Re: Problems with Interfaces
>
> Hi Gopi,
>
> On Mon, Oct 26, 2009 at 6:10 PM, Gopi <go...@gmail.com> wrote:
>
> >
> > > o  The @ManagedInterface "instances" are created by the runtime when
> you
> > > call createInstance(c).  You should not be defining a separate @Entity
> > > class.  This is like doubly defining your object model.
> > >
> > >
> >
> > Ok. I removed the @Entity from the class. So now in my persistence.xml,
> > instead of <class>EndpointObject</class>, I now have
> > <class>Endpoint</class>. Is this right?
> >
> > Yes, that's what I would expect.
>
>
> >
> > > o  To that end, your @GeneratedValue should be moved from your Entity
> > > class
> > > to your ManagedInterface interface.
> > >
> > >
> > Ok. Done.
> >
> > Good.
>
>
> > > o  And, it looks like you are doing a lot of extra processing with
> > > registration with the MetaDataRepository and ClassMetaData.  You should
> > > not
> > > have to mess around with these data structures.  After creating the
> > > instance
> > > and persisting it, the OpenJPA runtime should take care of the
> > > registration.
> > >
> > >
> >
> > The reason I am doing the extra processing is because, if I don't, I get
> > the
> > following error message. I found a solution to this in this forum at
> >
> >
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
> >
> >  [java] java.lang.IllegalArgumentException: No metadata was found for
> > managed interface Endpoint.
> >     [java]     at
> > org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
> >     [java]     at
> >
> >
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
> >     [java]     at
> >
> >
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
> >     [java]     at Main.main(Main.java:36)
> >
> > So how else do I get rid of this error message?
> >
>
> According to that post, this extra processing should not be necessary if
> you
> have included the ManagedInterface "entity" in the <class> element of
> persistence.xml.  So, even with the changes you did above, you are still
> getting this exception?
>
> From Pinaki's response...
>     "The metadata registration and classloading done in your code for
> managed interface *should* not be required if you specify the class name in
> <class> clause of persistence.xml. But please report if that is not the
> case."
>
>
> >
> > > o  One additional thought is how are you performing the enhancement
> > > processing [2]?  To be honest, I'm not entirely clear on how the
> > > @ManagedInterface instance creation integrates with our enhancement
> > > processing.  Maybe another developer can shed some light on this
> aspect.
> > >
> > >
> >
> > I am doing this by passing an arg to the jvm as follows in my build.xml
> > file.
> >
> > <target name="Main">
> >                <java classname="Main" failonerror="true" fork="yes">
> >                        <jvmarg
> > value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar"
> />
> >                        <classpath refid="TestJPA1.classpath" />
> >                </java>
> > </target>
> >
>
> If you are only using @ManagedInterfaces and no other @Entities, then this
> should not even be required.  Pinaki's other reply on this thread has
> indicated that due to the generated byte-codes that we do for the
> @ManagedInterface instance creation, all of the enhancement processing is
> already done.  But, if you have other @Entities, then the use of the
> -javaagent is an easy way to get your Entities enhanced.
>
> Kevin
>
>
> > --
> > View this message in context:
> > http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
>
>
>
>
>



      

Re: Problems with Interfaces

Posted by Michael Dick <mi...@gmail.com>.
Hi Gopi,

The ManagedInterface annotation is intended to be used when you don't have a
concrete class. Instead OpenJPA will generate one for you [1]. Having a
concrete implementation might be contributing to your problem.

That said, I think the specific error you're hitting is the result of not
listing com.ejb.entity.FordMushtang in persistence.xml (along with
com.ejb.entity.Drivable).

If you provide a list of entity types those are the only ones that get
enhanced. Basically you should list all the classes you plan on using.

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_interfaces

Hope this helps,
-mike

On Wed, Oct 28, 2009 at 9:15 AM, shriram <sh...@yahoo.com> wrote:

> Kevin,
>
> I just tried this as an example.
>
> Can you please let me know if something wrong in my assumption.
>
> @ManagedInterface
> interface Drivable
>
> class FordMushtang implements Drivable
>
> and my persistence.xml
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>     <class>com.ejb.entity.Drivable</class>
>
> <properties>
>      <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
>    </properties>
>
> I am getting an exception of
>
> <openjpa-2.0.0-M3-r422266:822833 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance
> "com.ejb.entity.FordMushtang[id=234234234]" to PersistenceCapable failed.
>  Ensure that it has been enhanced.
> FailedObject: com.ejb.entity.FordMushtang[id=234234234]
>        at
> org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4480)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2505)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2366)
>        at
> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1039)
>        at
> org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:696)
>        at jpatesting.Main.persist(Main.java:85)
>        at jpatesting.Main.main(Main.java:66)
>
>
>
>
>
> ________________________________
> From: Kevin Sutter <kw...@gmail.com>
> To: users@openjpa.apache.org
> Sent: Wed, October 28, 2009 8:53:07 AM
> Subject: Re: Problems with Interfaces
>
> Hi Gopi,
>
> On Mon, Oct 26, 2009 at 6:10 PM, Gopi <go...@gmail.com> wrote:
>
> >
> > > o  The @ManagedInterface "instances" are created by the runtime when
> you
> > > call createInstance(c).  You should not be defining a separate @Entity
> > > class.  This is like doubly defining your object model.
> > >
> > >
> >
> > Ok. I removed the @Entity from the class. So now in my persistence.xml,
> > instead of <class>EndpointObject</class>, I now have
> > <class>Endpoint</class>. Is this right?
> >
> > Yes, that's what I would expect.
>
>
> >
> > > o  To that end, your @GeneratedValue should be moved from your Entity
> > > class
> > > to your ManagedInterface interface.
> > >
> > >
> > Ok. Done.
> >
> > Good.
>
>
> > > o  And, it looks like you are doing a lot of extra processing with
> > > registration with the MetaDataRepository and ClassMetaData.  You should
> > > not
> > > have to mess around with these data structures.  After creating the
> > > instance
> > > and persisting it, the OpenJPA runtime should take care of the
> > > registration.
> > >
> > >
> >
> > The reason I am doing the extra processing is because, if I don't, I get
> > the
> > following error message. I found a solution to this in this forum at
> >
> >
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
> >
> >  [java] java.lang.IllegalArgumentException: No metadata was found for
> > managed interface Endpoint.
> >     [java]     at
> > org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
> >     [java]     at
> >
> >
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
> >     [java]     at
> >
> >
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
> >     [java]     at Main.main(Main.java:36)
> >
> > So how else do I get rid of this error message?
> >
>
> According to that post, this extra processing should not be necessary if
> you
> have included the ManagedInterface "entity" in the <class> element of
> persistence.xml.  So, even with the changes you did above, you are still
> getting this exception?
>
> From Pinaki's response...
>     "The metadata registration and classloading done in your code for
> managed interface *should* not be required if you specify the class name in
> <class> clause of persistence.xml. But please report if that is not the
> case."
>
>
> >
> > > o  One additional thought is how are you performing the enhancement
> > > processing [2]?  To be honest, I'm not entirely clear on how the
> > > @ManagedInterface instance creation integrates with our enhancement
> > > processing.  Maybe another developer can shed some light on this
> aspect.
> > >
> > >
> >
> > I am doing this by passing an arg to the jvm as follows in my build.xml
> > file.
> >
> > <target name="Main">
> >                <java classname="Main" failonerror="true" fork="yes">
> >                        <jvmarg
> > value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar"
> />
> >                        <classpath refid="TestJPA1.classpath" />
> >                </java>
> > </target>
> >
>
> If you are only using @ManagedInterfaces and no other @Entities, then this
> should not even be required.  Pinaki's other reply on this thread has
> indicated that due to the generated byte-codes that we do for the
> @ManagedInterface instance creation, all of the enhancement processing is
> already done.  But, if you have other @Entities, then the use of the
> -javaagent is an easy way to get your Entities enhanced.
>
> Kevin
>
>
> > --
> > View this message in context:
> > http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> > Sent from the OpenJPA Users mailing list archive at Nabble.com.
> >
>
>
>
>
>

Re: Problems with Interfaces

Posted by shriram <sh...@yahoo.com>.
Kevin,

I just tried this as an example.

Can you please let me know if something wrong in my assumption.

@ManagedInterface
interface Drivable

class FordMushtang implements Drivable

and my persistence.xml

<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
    <class>com.ejb.entity.Drivable</class>

<properties>
      <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
    </properties>

I am getting an exception of 

<openjpa-2.0.0-M3-r422266:822833 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.ejb.entity.FordMushtang[id=234234234]" to PersistenceCapable failed.  Ensure that it has been enhanced.
FailedObject: com.ejb.entity.FordMushtang[id=234234234]
        at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4480)
        at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2505)
        at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2366)
        at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1039)
        at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:696)
        at jpatesting.Main.persist(Main.java:85)
        at jpatesting.Main.main(Main.java:66)





________________________________
From: Kevin Sutter <kw...@gmail.com>
To: users@openjpa.apache.org
Sent: Wed, October 28, 2009 8:53:07 AM
Subject: Re: Problems with Interfaces

Hi Gopi,

On Mon, Oct 26, 2009 at 6:10 PM, Gopi <go...@gmail.com> wrote:

>
> > o  The @ManagedInterface "instances" are created by the runtime when you
> > call createInstance(c).  You should not be defining a separate @Entity
> > class.  This is like doubly defining your object model.
> >
> >
>
> Ok. I removed the @Entity from the class. So now in my persistence.xml,
> instead of <class>EndpointObject</class>, I now have
> <class>Endpoint</class>. Is this right?
>
> Yes, that's what I would expect.


>
> > o  To that end, your @GeneratedValue should be moved from your Entity
> > class
> > to your ManagedInterface interface.
> >
> >
> Ok. Done.
>
> Good.


> > o  And, it looks like you are doing a lot of extra processing with
> > registration with the MetaDataRepository and ClassMetaData.  You should
> > not
> > have to mess around with these data structures.  After creating the
> > instance
> > and persisting it, the OpenJPA runtime should take care of the
> > registration.
> >
> >
>
> The reason I am doing the extra processing is because, if I don't, I get
> the
> following error message. I found a solution to this in this forum at
>
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
>
>  [java] java.lang.IllegalArgumentException: No metadata was found for
> managed interface Endpoint.
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
>     [java]     at
>
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
>     [java]     at
>
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
>     [java]     at Main.main(Main.java:36)
>
> So how else do I get rid of this error message?
>

According to that post, this extra processing should not be necessary if you
have included the ManagedInterface "entity" in the <class> element of
persistence.xml.  So, even with the changes you did above, you are still
getting this exception?

>From Pinaki's response...
     "The metadata registration and classloading done in your code for
managed interface *should* not be required if you specify the class name in
<class> clause of persistence.xml. But please report if that is not the
case."


>
> > o  One additional thought is how are you performing the enhancement
> > processing [2]?  To be honest, I'm not entirely clear on how the
> > @ManagedInterface instance creation integrates with our enhancement
> > processing.  Maybe another developer can shed some light on this aspect.
> >
> >
>
> I am doing this by passing an arg to the jvm as follows in my build.xml
> file.
>
> <target name="Main">
>                <java classname="Main" failonerror="true" fork="yes">
>                        <jvmarg
> value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar" />
>                        <classpath refid="TestJPA1.classpath" />
>                </java>
> </target>
>

If you are only using @ManagedInterfaces and no other @Entities, then this
should not even be required.  Pinaki's other reply on this thread has
indicated that due to the generated byte-codes that we do for the
@ManagedInterface instance creation, all of the enhancement processing is
already done.  But, if you have other @Entities, then the use of the
-javaagent is an easy way to get your Entities enhanced.

Kevin


> --
> View this message in context:
> http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



      

Re: Problems with Interfaces

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Gopi,

On Mon, Oct 26, 2009 at 6:10 PM, Gopi <go...@gmail.com> wrote:

>
> > o  The @ManagedInterface "instances" are created by the runtime when you
> > call createInstance(c).  You should not be defining a separate @Entity
> > class.  This is like doubly defining your object model.
> >
> >
>
> Ok. I removed the @Entity from the class. So now in my persistence.xml,
> instead of <class>EndpointObject</class>, I now have
> <class>Endpoint</class>. Is this right?
>
> Yes, that's what I would expect.


>
> > o  To that end, your @GeneratedValue should be moved from your Entity
> > class
> > to your ManagedInterface interface.
> >
> >
> Ok. Done.
>
> Good.


> > o  And, it looks like you are doing a lot of extra processing with
> > registration with the MetaDataRepository and ClassMetaData.  You should
> > not
> > have to mess around with these data structures.  After creating the
> > instance
> > and persisting it, the OpenJPA runtime should take care of the
> > registration.
> >
> >
>
> The reason I am doing the extra processing is because, if I don't, I get
> the
> following error message. I found a solution to this in this forum at
>
> http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html
>
>  [java] java.lang.IllegalArgumentException: No metadata was found for
> managed interface Endpoint.
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
>     [java]     at
>
> org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
>     [java]     at
>
> org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
>     [java]     at Main.main(Main.java:36)
>
> So how else do I get rid of this error message?
>

According to that post, this extra processing should not be necessary if you
have included the ManagedInterface "entity" in the <class> element of
persistence.xml.  So, even with the changes you did above, you are still
getting this exception?

>From Pinaki's response...
     "The metadata registration and classloading done in your code for
managed interface *should* not be required if you specify the class name in
<class> clause of persistence.xml. But please report if that is not the
case."


>
> > o  One additional thought is how are you performing the enhancement
> > processing [2]?  To be honest, I'm not entirely clear on how the
> > @ManagedInterface instance creation integrates with our enhancement
> > processing.  Maybe another developer can shed some light on this aspect.
> >
> >
>
> I am doing this by passing an arg to the jvm as follows in my build.xml
> file.
>
> <target name="Main">
>                <java classname="Main" failonerror="true" fork="yes">
>                        <jvmarg
> value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar" />
>                        <classpath refid="TestJPA1.classpath" />
>                </java>
> </target>
>

If you are only using @ManagedInterfaces and no other @Entities, then this
should not even be required.  Pinaki's other reply on this thread has
indicated that due to the generated byte-codes that we do for the
@ManagedInterface instance creation, all of the enhancement processing is
already done.  But, if you have other @Entities, then the use of the
-javaagent is an easy way to get your Entities enhanced.

Kevin


> --
> View this message in context:
> http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: Problems with Interfaces

Posted by Gopi <go...@gmail.com>.


> o  The @ManagedInterface "instances" are created by the runtime when you
> call createInstance(c).  You should not be defining a separate @Entity
> class.  This is like doubly defining your object model.
> 
> 

Ok. I removed the @Entity from the class. So now in my persistence.xml,
instead of <class>EndpointObject</class>, I now have
<class>Endpoint</class>. Is this right?



> o  To that end, your @GeneratedValue should be moved from your Entity
> class
> to your ManagedInterface interface.
> 
> 
Ok. Done.



> o  And, it looks like you are doing a lot of extra processing with
> registration with the MetaDataRepository and ClassMetaData.  You should
> not
> have to mess around with these data structures.  After creating the
> instance
> and persisting it, the OpenJPA runtime should take care of the
> registration.
> 
> 

The reason I am doing the extra processing is because, if I don't, I get the
following error message. I found a solution to this in this forum at
http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-td1493116.html

  [java] java.lang.IllegalArgumentException: No metadata was found for
managed interface Endpoint.
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.newInstance(BrokerImpl.java:4319)
     [java] 	at
org.apache.openjpa.kernel.DelegatingBroker.newInstance(DelegatingBroker.java:1392)
     [java] 	at
org.apache.openjpa.persistence.EntityManagerImpl.createInstance(EntityManagerImpl.java:1243)
     [java] 	at Main.main(Main.java:36)

So how else do I get rid of this error message?



> o  One additional thought is how are you performing the enhancement
> processing [2]?  To be honest, I'm not entirely clear on how the
> @ManagedInterface instance creation integrates with our enhancement
> processing.  Maybe another developer can shed some light on this aspect.
> 
> 

I am doing this by passing an arg to the jvm as follows in my build.xml
file.

<target name="Main">
		<java classname="Main" failonerror="true" fork="yes">
			<jvmarg
value="-javaagent:/Users/gopi/packages/openjpa/openjpa-all-2.0.0-M3.jar" />
			<classpath refid="TestJPA1.classpath" />
		</java>
</target>
-- 
View this message in context: http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3895651.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Problems with Interfaces

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Gopi,
For being a new user to JPA and OpenJPA, you start with some pretty obscure
features...  :-)

For those of you playing along at home, ManagedInterfaces are an OpenJPA
feature [1] that allow you to define your entity object model using
Interfaces instead of Classes.  Not being an expert with this particular
feature myself, the following are my observations and suggestions...

o  The @ManagedInterface "instances" are created by the runtime when you
call createInstance(c).  You should not be defining a separate @Entity
class.  This is like doubly defining your object model.

o  To that end, your @GeneratedValue should be moved from your Entity class
to your ManagedInterface interface.

o  And, it looks like you are doing a lot of extra processing with
registration with the MetaDataRepository and ClassMetaData.  You should not
have to mess around with these data structures.  After creating the instance
and persisting it, the OpenJPA runtime should take care of the registration.

o  One additional thought is how are you performing the enhancement
processing [2]?  To be honest, I'm not entirely clear on how the
@ManagedInterface instance creation integrates with our enhancement
processing.  Maybe another developer can shed some light on this aspect.

Good luck,
Kevin


[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_pc_interfaces
[2]
http://webspherepersistence.blogspot.com/2009/02/openjpa-enhancement.html

On Mon, Oct 26, 2009 at 4:08 PM, Gopi <go...@gmail.com> wrote:

>
> Sorry, I forgot to post the actual exception. Here it is...
>
>  [java] 1009  TestJPA1  INFO   [main] openjpa.Enhance - Enhancing type
> "class Endpoint$1806393359openjpaimpl".
>     [java] <openjpa-2.0.0-M3-r422266:822833 fatal store error>
> org.apache.openjpa.persistence.RollbackException: The transaction has been
> rolled back.  See the nested exceptions for details on the errors that
> occurred.
>     [java]     at
>
> org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:574)
>     [java]     at Main.main(Main.java:40)
>     [java] Caused by: <openjpa-2.0.0-M3-r422266:822833 fatal general error>
> org.apache.openjpa.persistence.PersistenceException: The transaction has
> been rolled back.  See the nested exceptions for details on the errors that
> occurred.
>     [java]     at
>
> org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2249)
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2096)
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1994)
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1912)
>     [java]     at
>
> org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
>     [java]     at
> org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1436)
>     [java]     at
>
> org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:895)
>     [java]     at
>
> org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:557)
>     [java]     ... 1 more
>     [java] Caused by: <openjpa-2.0.0-M3-r422266:822833 nonfatal general
> error> org.apache.openjpa.persistence.PersistenceException: ERROR: relation
> "endpoint" does not exist
>     [java]   Position: 13 {prepstmnt 778653458 INSERT INTO Endpoint (id,
> site_name) VALUES (?, ?) [params=(long) 351, (String) site_name1]} [code=0,
> state=42P01]
>     [java] FailedObject: Endpoint$1806393359openjpaimpl@6ac67a88
>     [java]     at
> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4590)
>     [java]     at
>
> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4543)
>     [java]     at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
>     [java]     at
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:141)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:80)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:97)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:85)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:106)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:677)
>     [java]     at
>
> org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
>     [java]     ... 8 more
>     [java] Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
> ERROR: relation "endpoint" does not exist
>     [java]   Position: 13 {prepstmnt 778653458 INSERT INTO Endpoint (id,
> site_name) VALUES (?, ?) [params=(long) 351, (String) site_name1]} [code=0,
> state=42P01]
>     [java]     at
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:239)
>     [java]     at
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:70)
>     [java]     at
>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1069)
>     [java]     at
>
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)
>     [java]     at
>
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1612)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:246)
>     [java]     at
>
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:116)
>     [java]     ... 18 more
> --
> View this message in context:
> http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3894961.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Re: Problems with Interfaces

Posted by Gopi <go...@gmail.com>.
Sorry, I forgot to post the actual exception. Here it is...

 [java] 1009  TestJPA1  INFO   [main] openjpa.Enhance - Enhancing type
"class Endpoint$1806393359openjpaimpl".
     [java] <openjpa-2.0.0-M3-r422266:822833 fatal store error>
org.apache.openjpa.persistence.RollbackException: The transaction has been
rolled back.  See the nested exceptions for details on the errors that
occurred.
     [java] 	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:574)
     [java] 	at Main.main(Main.java:40)
     [java] Caused by: <openjpa-2.0.0-M3-r422266:822833 fatal general error>
org.apache.openjpa.persistence.PersistenceException: The transaction has
been rolled back.  See the nested exceptions for details on the errors that
occurred.
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2249)
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2096)
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1994)
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1912)
     [java] 	at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
     [java] 	at
org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1436)
     [java] 	at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:895)
     [java] 	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:557)
     [java] 	... 1 more
     [java] Caused by: <openjpa-2.0.0-M3-r422266:822833 nonfatal general
error> org.apache.openjpa.persistence.PersistenceException: ERROR: relation
"endpoint" does not exist
     [java]   Position: 13 {prepstmnt 778653458 INSERT INTO Endpoint (id,
site_name) VALUES (?, ?) [params=(long) 351, (String) site_name1]} [code=0,
state=42P01]
     [java] FailedObject: Endpoint$1806393359openjpaimpl@6ac67a88
     [java] 	at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4590)
     [java] 	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4543)
     [java] 	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
     [java] 	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
     [java] 	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:141)
     [java] 	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:80)
     [java] 	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:97)
     [java] 	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:85)
     [java] 	at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:550)
     [java] 	at
org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:106)
     [java] 	at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:59)
     [java] 	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:103)
     [java] 	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:76)
     [java] 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:677)
     [java] 	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
     [java] 	... 8 more
     [java] Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
ERROR: relation "endpoint" does not exist
     [java]   Position: 13 {prepstmnt 778653458 INSERT INTO Endpoint (id,
site_name) VALUES (?, ?) [params=(long) 351, (String) site_name1]} [code=0,
state=42P01]
     [java] 	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:239)
     [java] 	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:70)
     [java] 	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:1069)
     [java] 	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)
     [java] 	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:285)
     [java] 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1612)
     [java] 	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:246)
     [java] 	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:116)
     [java] 	... 18 more
-- 
View this message in context: http://n2.nabble.com/Problems-with-Interfaces-tp3894934p3894961.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.