openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-493) openjpa.jdbc.Schema property set causes wrong SQL queries when reading OPENJPA_SEQUENCE_TABLE
Date Mon, 23 Jun 2008 19:26:45 GMT

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

Kevin Sutter commented on OPENJPA-493:
--------------------------------------

Looks like you need to specify both the @Table and @TableGenerator annotations with a schema
name element to reproduce the problem.  I just updated the Dog.java Entity and ran the TestTableGenerator
to reproduce the problem with the following changes to Dog.java:

@Entity
@Table(name="Dog", schema="MY")
public class Dog {
    @Id
    @TableGenerator(name = "Dog_Gen", table = "ID_Gen", schema="MY",
            pkColumnName = "GEN_NAME", valueColumnName = "GEN_VAL", 
            pkColumnValue = "ID2", initialValue = 20, allocationSize = 10)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Dog_Gen")

I did this with the 1.0.x release.  

> openjpa.jdbc.Schema property set causes wrong SQL queries when reading OPENJPA_SEQUENCE_TABLE
> ---------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-493
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-493
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.0.0, 1.0.1
>         Environment: Windows XP, Java 5.0 IBM.
>            Reporter: Przemek Koprowski
>         Attachments: SchemaPropertyProblem.zip
>
>
> When openjpa.jdbc.Schema is defined inserting object into the database causes exception
because of wrong SQL query generation.
> In the sample openjpa.jdbc.Schema="KB", generates  SQL: SELECT SEQUENCE_VALUE FROM KB.KB.OPENJPA_SEQUENCE_TABLE
WHERE ID = ? FOR UPDATE WITH RR.
> This problem doesn't occur in version 0.9.7.
> Trace:
> <openjpa-1.0.1-r420667:592145 fatal store error> org.apache.openjpa.persistence.RollbackException:
Attempt to update the sequence table "OPENJPA_SEQUENCE_TABLE" failed.  The sequence table
is typically created when you run the mappingtool's refresh action on any datastore identity
class. If you have not run the mappingtool but want to create the sequence table, run:
> java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
> 	at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:419)
> 	at TestCase.testL1ProductEasier(TestCase.java:30)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:615)
> 	at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
> 	at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
> 	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
> 	at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
> 	at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
> 	at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
> 	at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
> 	at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
> 	at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
> 	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
> 	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)
> Caused by: <openjpa-1.0.1-r420667:592145 nonfatal general error> org.apache.openjpa.persistence.PersistenceException:
Attempt to update the sequence table "OPENJPA_SEQUENCE_TABLE" failed.  The sequence table
is typically created when you run the mappingtool's refresh action on any datastore identity
class. If you have not run the mappingtool but want to create the sequence table, run:
> java org.apache.openjpa.jdbc.kernel.TableJDBCSeq -action add
> 	at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:3938)
> 	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:97)
> 	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:75)
> 	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:371)
> 	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:266)
> 	at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)
> 	at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
> 	at org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:557)
> 	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:450)
> 	at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:426)
> 	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:541)
> 	at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:134)
> 	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:501)
> 	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2770)
> 	at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:39)
> 	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:940)
> 	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1892)
> 	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1852)
> 	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1770)
> 	at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
> 	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1292)
> 	at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:861)
> 	at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:408)
> 	... 21 more
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Syntax error: Encountered
"." at line 1, column 33. {SELECT SEQUENCE_VALUE FROM KB.KB.OPENJPA_SEQUENCE_TABLE WHERE ID
= ? FOR UPDATE WITH RR} [code=20000, state=42X01]
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:201)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:57)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:228)
> 	at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:163)
> 	at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:140)
> 	at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:152)
> 	at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:475)
> 	at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:455)
> 	at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:444)
> 	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.getSequence(TableJDBCSeq.java:467)
> 	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.setSequence(TableJDBCSeq.java:511)
> 	at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:368)
> 	... 41 more

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


Mime
View raw message