[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5042) TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range

Mike Youngstrom (JIRA) noreply at atlassian.com
Sat May 15 19:27:25 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37151#action_37151 ] 

Mike Youngstrom commented on HHH-5042:
--------------------------------------

I wonder if fixing this issue might have caused a regression. In my application I'm using Oracle and @SequenceGenerator with an allocationSize=1 after upgrading to 3.5.2 I get an error on startup: If I change my allocationSize to 2 then it starts up fine but debugging into LegacyHiLoAlgorithmOptimizer it sets a value of 1.

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: org.lds.stack.stack-pet-store-ws] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:896)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
... 38 more
Caused by: org.hibernate.MappingException: Could not instantiate id generator [entity-name=org.lds.stack.petstore.model.Animal]
at org.hibernate.id.factory.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:117)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:178)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:257)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:887)
... 43 more
Caused by: org.hibernate.HibernateException: increment size cannot be less than 1
at org.hibernate.id.enhanced.OptimizerFactory$LegacyHiLoAlgorithmOptimizer.<init>(OptimizerFactory.java:336)
at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:64)
at org.hibernate.id.factory.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:110)
... 48 more

> TableGenerator does not increment hibernate_sequences.next_hi_value anymore after having exhausted the current lo-range
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5042
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5042
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0.Beta-1, 3.5.0-Beta-2, 3.5.0-Beta-3, 3.5.0-Beta-4, 3.5.0-CR-1, 3.5.0-CR-2, 3.5.1
>         Environment: Hibernate: 3.5 , db: HSQLDB (not relevant)
>            Reporter: Guenther Demetz
>            Assignee: Steve Ebersole
>            Priority: Critical
>             Fix For: 3.5.2, 3.6
>
>         Attachments: TestHiloGenerators.jar, TestTableGenerator.java
>
>          Time Spent: 3h 35m
>  Remaining Estimate: 0h
>
> This bug is new in 3.5
> In version 3.5 class MultipleHiLoPerTableGenerator.java was modified introducing a 
> new increment variable 
>   IntegralDataTypeHolder value;
> along with 
>   int lo;
> The problem in the new code is that only value get's incremented whilst variable lo 
> is still used to check when a new hiVal must be obtained.
> if ( lo > maxLo ) {
> 	IntegralDataTypeHolder hiVal = (IntegralDataTypeHolder) doWorkInNewTransaction( session );
> as lo is never incremented, MultipleHiLoPerTableGenerator continues to deliver numbers without ever update 
> hibernate_sequences.next_hi_value on the database (only one unique update is propagates at the first insert)
> This lead to duplicate keys as soon another session from another sessionfactory tries to insert new objects on the concerning table.
> Please see attached testcase.
> IMPORTANT ADVICE TO RUN THE TESTCASE: 
> as the testcase uses 2 sessionfactories hibernate.hbm2ddl.auto=create cannot be used!!
> Schema has to be exported separately and the testcase must run without hbm2ddl.auto property!
> Here the schema for HSQLDB:
> create table A (oid bigint not null, name varchar(255), version integer not null, primary key (oid), unique (name)) 
> create table hibernate_sequences ( sequence_name varchar(255),  sequence_next_hi_value integer )  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list