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 <[email protected]> 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$1806393359openjpai...@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.
>

Reply via email to