-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error with hibernate hilo generator
PostPosted: Thu May 13, 2010 12:03 pm 
Newbie

Joined: Sun Feb 15, 2009 11:36 am
Posts: 9
Location: Switzerland
Hi

A strange error which I cannot reproduce drives me crazy.
It is a desktop application and the data are modified on a single PC.

All entities extend a base entity with the following definition for the identifier:
Code:
   @Id @GeneratedValue(generator="hibseq")
   @org.hibernate.annotations.GenericGenerator(name="hibseq", strategy="hilo",
         parameters = {
            @org.hibernate.annotations.Parameter(name="table", value = "ENTITY_HI_VALUES"),
            @org.hibernate.annotations.Parameter(name="column", value = "HI"),
            @org.hibernate.annotations.Parameter(name="max_lo", value = "5")
         }
   )
   public Long getId() {
      return id;
   }

This means that all entities use the same generator.

The database is DB2. The relevant configuration is:
Code:
      <!-- Hibernate connection pool -->
      <property name="c3p0.min_size">2</property>
      <property name="c3p0.max_size">5</property>
      <property name="c3p0.timeout">5000</property>
      <property name="c3p0.max_statements">50</property>
      <property name="c3p0.idle_test_period">3000</property>

      <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>

      <!-- Disable the second-level cache  -->
      <property name="cache.use_second_level_cache">false</property>
      <!--  property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>  -->


During development this worked fine. But now in production the generator seems to “jump” and to deliver inconsistent values. On one occasion the id was 82 whereas the ENTITY_HI_VALUES.HI was 264. Consequently a constraint violation exception resulted.
The ids in the database show that on another occasion the id jumped from 524 to 3150. Later on it jumped again causing a constraint violation. ENTITY_HI_VALUES.HI was 535 which does not make sense looking at the stored ids.
I am quite lost and am very thankful for any help.

Regards, Martin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.