Hi Martin,
Your configuration is perfect. I wonder if the OpenJPA team might be
aware of anything that might prevent the SynchronizeMappings feature
from working on PostgreSQL. Of perhaps if there's a better way to
debug exactly what table definitions were created in the
synchronization process.
-David
On Jan 23, 2009, at 5:02 PM, Martin Uhlir wrote:
Hi all,
I added new DataSources in my openejb.xml file:
<Resource id="MyDB" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/TestDB
UserName xxx
Password yyy
JtaManaged true
</Resource>
<Resource id="MyDBun" type="DataSource">
JdbcDriver org.postgresql.Driver
JdbcUrl jdbc:postgresql://localhost/TestDB
UserName xxx
Password yyy
JtaManaged false
</Resource>
Then I deployed an EJB application with this persistence.xml
<persistence-unit name="EJB_Module">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
provider>
<jta-data-source>MyDB</jta-data-source>
<non-jta-data-source>MyDBun</non-jta-data-source>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
So according to SynchronizeMappings the tables etc. shall be
automatically created.
But running the application I get following exception:
<openjpa-1.2.0-r422266:683325 fatal store error>
org.apache.openjpa.util.StoreException: The transaction has been
rolled back. See the nested exceptions for details on the errors
that occurred.
at
org
.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:
2163)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:
1908)
at
org
.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:
1826)
at
org
.apache
.geronimo
.transaction
.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:514)
at
org
.apache
.geronimo
.transaction
.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:499)
at
org
.apache
.geronimo
.transaction
.manager.TransactionImpl.beforePrepare(TransactionImpl.java:400)
at
org
.apache
.geronimo
.transaction.manager.TransactionImpl.commit(TransactionImpl.java:257)
at
org
.apache
.geronimo
.transaction
.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:
245)
at
org
.apache
.openejb
.core
.transaction
.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:
291)
at
org
.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:71)
at
org
.apache
.openejb
.core
.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:
74)
at
org
.apache
.openejb
.core.stateless.StatelessContainer._invoke(StatelessContainer.java:
231)
at
org
.apache
.openejb
.core.stateless.StatelessContainer.invoke(StatelessContainer.java:169)
at
org
.apache
.openejb
.server
.ejbd
.EjbRequestHandler
.doEjbObject_BUSINESS_METHOD(EjbRequestHandler.java:238)
at
org
.apache
.openejb
.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:
129)
at
org
.apache
.openejb.server.ejbd.EjbDaemon.processEjbRequest(EjbDaemon.java:196)
at org.apache.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:
149)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
71)
at org.apache.openejb.server.ejbd.KeepAliveServer
$Session.service(KeepAliveServer.java:213)
at
org
.apache
.openejb.server.ejbd.KeepAliveServer.service(KeepAliveServer.java:233)
at org.apache.openejb.server.ejbd.EjbServer.service(EjbServer.java:
66)
at org.apache.openejb.server.ServicePool$2.run(ServicePool.java:91)
at org.apache.openejb.server.ServicePool$3.run(ServicePool.java:120)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
org.apache.openjpa.util.StoreException: ERROR: relation "country"
does not exist {prepstmnt 16963612 INSERT INTO Country (id, name)
VALUES (?, ?) [params=(long) 5, (String) aaa]} [code=0, state=42P01]
FailedObject: carpool.entities.coun...@17a687b
at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:
4238)
at
org
.apache
.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:
4203)
at
org
.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:
102)
at
org
.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
at
org
.apache
.openjpa
.jdbc
.kernel
.PreparedStatementManagerImpl
.flushAndUpdate(PreparedStatementManagerImpl.java:131)
at
org
.apache
.openjpa
.jdbc
.kernel
.BatchingPreparedStatementManagerImpl
.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:82)
at
org
.apache
.openjpa
.jdbc
.kernel
.PreparedStatementManagerImpl
.flushInternal(PreparedStatementManagerImpl.java:89)
at
org
.apache
.openjpa
.jdbc
.kernel
.PreparedStatementManagerImpl
.flush(PreparedStatementManagerImpl.java:72)
at
org
.apache
.openjpa
.jdbc
.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
543)
at
org
.apache
.openjpa
.jdbc
.kernel.ConstraintUpdateManager.flush(ConstraintUpdateManager.java:
105)
at
org
.apache
.openjpa
.jdbc
.kernel
.BatchingConstraintUpdateManager
.flush(BatchingConstraintUpdateManager.java:59)
at
org
.apache
.openjpa
.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
89)
at
org
.apache
.openjpa
.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:
72)
at
org
.apache
.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
at
org
.apache
.openjpa
.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
... 26 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR:
relation "country" does not exist {prepstmnt 16963612 INSERT INTO
Country (id, name) VALUES (?, ?) [params=(long) 5, (String) aaa]}
[code=0, state=42P01]
at
org
.apache
.openjpa
.lib
.jdbc
.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access
$700(LoggingConnectionDecorator.java:57)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator
$LoggingConnection
$
LoggingPreparedStatement
.executeUpdate(LoggingConnectionDecorator.java:866)
at
org
.apache
.openjpa
.lib
.jdbc
.DelegatingPreparedStatement
.executeUpdate(DelegatingPreparedStatement.java:269)
at
org
.apache
.openjpa
.lib
.jdbc
.DelegatingPreparedStatement
.executeUpdate(DelegatingPreparedStatement.java:269)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager
$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
at
org
.apache
.openjpa
.jdbc
.kernel
.PreparedStatementManagerImpl
.executeUpdate(PreparedStatementManagerImpl.java:151)
at
org
.apache
.openjpa
.jdbc
.kernel
.PreparedStatementManagerImpl
.flushAndUpdate(PreparedStatementManagerImpl.java:120)
... 36 more
What does this '.....relation "country" does not exist".....' mean?
I'm just using this simple entity bean which I try to persist in a
stateless session bean.
@Entity
public class Country {
private Long id;
private String name;
public void setId(Long id) {
this.id = id;
}
@Id
public Long getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
When I change my persistence.xml to the DataSources provided by
openejb by default
<jta-data-source>My DataSource</jta-data-source>
<non-jta-data-source>My Unmanaged DataSource</non-jta-data-source>
then everything works just fine (but I don't want to use the default
HSQL database).
Thank you for any help in advance.