[ 
https://issues.apache.org/jira/browse/OPENJPA-1947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Vermeulen updated OPENJPA-1947:
-------------------------------

    Description: 
I use hsqldb for simple tests and let OpenJPA generate the tables with the line
<property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)" />
in persistence.xml.

When I make an entity with an id column like:

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;

And possibly some relations that do not result in extra columns in the table, 
OpenJPA generates wrong SQL when persisting a new entity:

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Unexpected token: 
) in statement [INSERT INTO ProductOrder () VALUES ()] {INSERT INTO 
ProductOrder () VALUES ()} [code=-11, state=37000]
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:237)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:70)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:289)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
        at 
org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:155)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
        at 
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$RefCountConnection.prepareStatement(JDBCStoreManager.java:1664)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:175)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.prepareStatement(PreparedStatementManagerImpl.java:289)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:112)
        at 
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:81)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)


EDIT: I verified that ms sql server also suffers from this. 
...
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Incorrect syntax 
near ')'. {prepstmnt 12767107 INSERT INTO ProductOrder () VALUES ()} [code=102, 
state=S0001]
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:281)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:72)
....

  was:
I use hsqldb for simple tests and let OpenJPA generate the tables with the line
<property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)" />
in persistence.xml.

When I make an entity with an id column like:

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;

And possibly some relations that do not result in extra columns in the table, 
OpenJPA generates wrong SQL when persisting a new entity:

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Unexpected token: 
) in statement [INSERT INTO ProductOrder () VALUES ()] {INSERT INTO 
ProductOrder () VALUES ()} [code=-11, state=37000]
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:237)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:70)
        at 
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:289)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
        at 
org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:155)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
        at 
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$RefCountConnection.prepareStatement(JDBCStoreManager.java:1664)
        at 
org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:175)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.prepareStatement(PreparedStatementManagerImpl.java:289)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:112)
        at 
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:81)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
        at 
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)


        Summary: GenerationType.IDENTITY generates incorrect sql when the table 
has only one column  (was: hsqldb and GenerationType.IDENTITY generates 
incorrect sql when the table has only one column)

> GenerationType.IDENTITY generates incorrect sql when the table has only one 
> column
> ----------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1947
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1947
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Vermeulen
>            Priority: Minor
>
> I use hsqldb for simple tests and let OpenJPA generate the tables with the 
> line
> <property name="openjpa.jdbc.SynchronizeMappings" 
> value="buildSchema(ForeignKeys=true)" />
> in persistence.xml.
> When I make an entity with an id column like:
>       @Id
>       @GeneratedValue(strategy = GenerationType.IDENTITY)
>       private Long id;
> And possibly some relations that do not result in extra columns in the table, 
> OpenJPA generates wrong SQL when persisting a new entity:
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Unexpected 
> token: ) in statement [INSERT INTO ProductOrder () VALUES ()] {INSERT INTO 
> ProductOrder () VALUES ()} [code=-11, state=37000]
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:237)
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:70)
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:289)
>       at 
> org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
>       at 
> org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:155)
>       at 
> org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
>       at 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$RefCountConnection.prepareStatement(JDBCStoreManager.java:1664)
>       at 
> org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:175)
>       at 
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.prepareStatement(PreparedStatementManagerImpl.java:289)
>       at 
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:112)
>       at 
> org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(BatchingPreparedStatementManagerImpl.java:81)
>       at 
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(PreparedStatementManagerImpl.java:99)
>       at 
> org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(PreparedStatementManagerImpl.java:87)
> EDIT: I verified that ms sql server also suffers from this. 
> ...
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Incorrect 
> syntax near ')'. {prepstmnt 12767107 INSERT INTO ProductOrder () VALUES ()} 
> [code=102, state=S0001]
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:281)
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:257)
>       at 
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1000(LoggingConnectionDecorator.java:72)
> ....

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to