You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Mark Struberg (Jira)" <ji...@apache.org> on 2021/04/07 05:49:00 UTC

[jira] [Commented] (OPENJPA-2797) SynchronizedMapping does not detect existing sequence

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

Mark Struberg commented on OPENJPA-2797:
----------------------------------------

hi! does that sequence exist in another schema? we might have an issue in that area.

> SynchronizedMapping does not detect existing sequence
> -----------------------------------------------------
>
>                 Key: OPENJPA-2797
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2797
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 3.1.0
>         Environment: TomEE 8.0, PostGreSQL 10
>            Reporter: Christophe Noel
>            Priority: Major
>
> When doing the JDBC Synchronization, the existing sequence are not detected and an ReportingSQLException is reported.
> The SequenceGenerator and column definition is shown below. Note that the database is PostGreSQL 10 and the tables/sequences are located in a dedicated YYY schema.
>  
> {code:java}
> @Id
> @SequenceGenerator(name="XXX_SEQUENCE",sequenceName="XXX_SEQ", initialValue=SequenceConstants.INITIAL_SEQUENCE_VALUE, schema = "YYY")
>  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="XXX_SEQUENCE")
>  @Column(name = "ID")
>  private long id;{code}
>  
> Properties:
>  
> {code:java}
> <property name="javax.persistence.schema-generation.database.action" value="create"/>
>  <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>{code}
>  
> Exception reported:
>  
> {code:java}
> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: relation "xxx_seq" already exists {stmnt 392461001 CREATE SEQUENCE information_schema.XXX_SEQ START WITH 1000 INCREMENT BY 50} [code=0, state=42P07]
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:203)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:58)
> 	at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingStatement.executeUpdate(LoggingConnectionDecorator.java:955)
> 	at org.apache.openjpa.lib.jdbc.DelegatingStatement.executeUpdate(DelegatingStatement.java:123)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.executeSQL(SchemaTool.java:1377)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.createSequence(SchemaTool.java:1137)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.buildSchema(SchemaTool.java:580)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:562)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:401)
> 	at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:373)
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)