openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dianne Richards" <diann...@gmail.com>
Subject Re: ManagedInterface
Date Mon, 15 Dec 2008 22:25:10 GMT
Hi - I have a quick question. Have you specified Table in a <class> element
in your persistence.xml file?

On Sun, Dec 14, 2008 at 7:30 AM, jc222 <jc222@free.fr> wrote:

>
> Hi all :-)
>
> I'm trying to use OpenJPA with an eclipse eCore model.
>
> The model is defined with java interfaces and java class that implements
> the
> interfaces:
>
> Here is an example:
>
> @ManagedInterface
> @Embeddable
> public interface Param extends EObject {
> double getParam();
> void setParam(double);
> }
>
> @ManagedInterface
> @Entity
> @Table(name = "table")
> public interface Table extends EObject {
> @Embedded
> @AttributeOverride(name = "param", column = @Column(name = "newparam"))
> Param getNewParam();
> void setNewParam(Param param);
> @Transient
> int getFoo();
> void setFoo();
> }
>
> public class ParamImpl extends EObjectImpl implements Param {
> ....
> }
>
> public class Table Impl extends EObjectImpl implements Table {
> ....
> }
>
> -----------------------
>
> The DB shema (generated with MappingTool) is good for me.
>
> My code to persist:
>
> Table table= TableFactoryImpl.eINSTANCE.createTable();
> em.getTransaction().begin();
> em.persist(table);
> em.getTransaction().commit();
>
>
> But I can't persist TableImpl objects. There is no mapping between
> TableImpl
> & Table. How can I do that ?
>
> <openjpa-1.2.0-r422266:683325 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance
> "com.e222.impl.TableImpl@1c9e67a (id: 0)" to PersistenceCapable failed.
> Ensure that it has been enhanced.
> FailedObject: com.e222.impl.TableImpl@1c9e67a (id: 0)
>        at
>
> org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4353)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2419)
>        at
> org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2280)
>        at
>
> org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1021)
>        at
>
> org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:645)
>        at com.e222..EJBTable.createTable(EJBTable.java:65)
>        at test.e222.EJBTableTest.testCreateT(EJBTableTest.java:37)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>        at java.lang.reflect.Method.invoke(Unknown Source)
>        at junit.framework.TestCase.runTest(TestCase.java:164)
>        at junit.framework.TestCase.runBare(TestCase.java:130)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:120)
>        at junit.framework.TestSuite.runTest(TestSuite.java:230)
>        at junit.framework.TestSuite.run(TestSuite.java:225)
>        at
>
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>        at
>
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>        at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>        at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>        at
>
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>
> If I use
> OpenJPAEntityManager em = ...;
> Table table= em.createInstance(Table.class);
>
> As in documentation.
> I raise an exception when I set my transient field foo ...
>
> Any idea ?
> Many Thanks
>
> --
> View this message in context:
> http://n2.nabble.com/ManagedInterface-tp1654454p1654454.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>


-- 
Thanks - Dianne

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message