org.hibernate.MappingException: Dialect does not support pooled sequences

Hibernate JIRA | Damir Malenicic | 8 years ago
  1. 0

    While generating DDL scripts for mapping files that declare id <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator"> the following exception is thrown: org.hibernate.MappingException: Dialect does not support pooled sequences at org.hibernate.dialect.Dialect.getCreateSequenceString(Dialect.java:701) at org.hibernate.dialect.Dialect.getCreateSequenceStrings(Dialect.java:659) at org.hibernate.id.enhanced.SequenceStructure.sqlCreateStrings(SequenceStructure.java:139) at org.hibernate.id.enhanced.SequenceStyleGenerator.sqlCreateStrings(SequenceStyleGenerator.java:328) at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:945) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:129) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91) I suspect the cause is in org.hibernate.dialect.Dialect#getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) if ( supportsPooledSequences() ) { return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize; } throw new MappingException( "Dialect does not support pooled sequences" ); This call requires not just that dialect supports sequences but that dialect supports pooled sequences. But the algorithm that tries to determine whether the table should be used to emulate the sequence lets the dialects that supports sequences but not pooled sequences to slip through. It looks like the DB2 and SAPDB dialects fail in this category because of: org.hibernate.id.enhanced.SequenceStyleGenerator#configure(Type type, Properties params, Dialect dialect) ... if ( dialect.supportsSequences() && !forceTableUse ) { if ( OptimizerFactory.POOL.equals( optimizationStrategy ) && !dialect.supportsPooledSequences() ) { forceTableUse = true; log.info( "Forcing table use for sequence-style generator due to pooled optimizer selection where db does not support pooled sequences" ); } } To workaround the problem I have created my generator that overrides SequenceStyleGenerator#configure, somethng like: public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if (dialect.supportsSequences() && !dialect.supportsPooledSequences()) { params.setProperty(FORCE_TBL_PARAM, "true"); } super.configure(type, params, dialect); Attached is a zip file with a small maven project with unit-test that replicates the problem. It generates DDL for different databases: Hipersonic, Derby, Oracle, MySql, PostgreSQL, MSSQL, DB2, and SAPDB. The data-model contains 2 tables Person and Event in many-to-many relation.

    Hibernate JIRA | 8 years ago | Damir Malenicic
    org.hibernate.MappingException: Dialect does not support pooled sequences
  2. 0

    While generating DDL scripts for mapping files that declare id <generator class="org.hibernate.id.enhanced.SequenceStyleGenerator"> the following exception is thrown: org.hibernate.MappingException: Dialect does not support pooled sequences at org.hibernate.dialect.Dialect.getCreateSequenceString(Dialect.java:701) at org.hibernate.dialect.Dialect.getCreateSequenceStrings(Dialect.java:659) at org.hibernate.id.enhanced.SequenceStructure.sqlCreateStrings(SequenceStructure.java:139) at org.hibernate.id.enhanced.SequenceStyleGenerator.sqlCreateStrings(SequenceStyleGenerator.java:328) at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:945) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:129) at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91) I suspect the cause is in org.hibernate.dialect.Dialect#getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) if ( supportsPooledSequences() ) { return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize; } throw new MappingException( "Dialect does not support pooled sequences" ); This call requires not just that dialect supports sequences but that dialect supports pooled sequences. But the algorithm that tries to determine whether the table should be used to emulate the sequence lets the dialects that supports sequences but not pooled sequences to slip through. It looks like the DB2 and SAPDB dialects fail in this category because of: org.hibernate.id.enhanced.SequenceStyleGenerator#configure(Type type, Properties params, Dialect dialect) ... if ( dialect.supportsSequences() && !forceTableUse ) { if ( OptimizerFactory.POOL.equals( optimizationStrategy ) && !dialect.supportsPooledSequences() ) { forceTableUse = true; log.info( "Forcing table use for sequence-style generator due to pooled optimizer selection where db does not support pooled sequences" ); } } To workaround the problem I have created my generator that overrides SequenceStyleGenerator#configure, somethng like: public void configure(Type type, Properties params, Dialect dialect) throws MappingException { if (dialect.supportsSequences() && !dialect.supportsPooledSequences()) { params.setProperty(FORCE_TBL_PARAM, "true"); } super.configure(type, params, dialect); Attached is a zip file with a small maven project with unit-test that replicates the problem. It generates DDL for different databases: Hipersonic, Derby, Oracle, MySql, PostgreSQL, MSSQL, DB2, and SAPDB. The data-model contains 2 tables Person and Event in many-to-many relation.

    Hibernate JIRA | 8 years ago | Damir Malenicic
    org.hibernate.MappingException: Dialect does not support pooled sequences
  3. 0

    Hibernate Entity Cannot determine type of @ManyToOne mapping on @Id column

    soso.io | 1 year ago
    org.hibernate.MappingException: Could not determine type for: com.***.inventory.model.clearance.LegacyNode, at table: LegacyClearanceNodeMapping, for columns: [org.hibernate.mapping.Column(clearanceNode)]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    JAVA - JPA Hibernate One-to-One relationship - efreedom

    efreedom.net | 1 year ago
    org.hibernate.MappingException: Could not determine type for: Person, at table: OtherInfo, for columns: [org.hibernate.mapping.Column(person)]
  6. 0

    Hibernate Entity Cannot determine type of @ManyToOne mapping on @Id column

    dolinked.com | 1 year ago
    org.hibernate.MappingException: Could not determine type for: com.***.inventory.model.clearance.LegacyNode, at table: LegacyClearanceNodeMapping, for columns: [org.hibernate.mapping.Column(clearanceNode)]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.MappingException

      Dialect does not support pooled sequences

      at org.hibernate.dialect.Dialect.getCreateSequenceString()
    2. Hibernate
      SchemaExport.<init>
      1. org.hibernate.dialect.Dialect.getCreateSequenceString(Dialect.java:701)
      2. org.hibernate.dialect.Dialect.getCreateSequenceStrings(Dialect.java:659)
      3. org.hibernate.id.enhanced.SequenceStructure.sqlCreateStrings(SequenceStructure.java:139)
      4. org.hibernate.id.enhanced.SequenceStyleGenerator.sqlCreateStrings(SequenceStyleGenerator.java:328)
      5. org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:945)
      6. org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:129)
      7. org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
      7 frames