-->
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.  [ 10 posts ] 
Author Message
 Post subject: What is max_lo in hilo generator ?
PostPosted: Mon Jan 17, 2005 4:39 pm 
Newbie

Joined: Fri Dec 17, 2004 12:17 pm
Posts: 5
What does max_lo parameter mean in Hilo generator configuration?
I've been searching everywhere for this.
Looking at source code doesn't make it clear.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 5:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
number of ids generated before fetching a new hi value


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 5:58 pm 
Newbie

Joined: Fri Dec 17, 2004 12:17 pm
Posts: 5
I set to 0 it will be sequental, like 1,2,3,4,5 ?
and If set to 1 it will be 1,3,5,7 ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 6:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No - please read up on how HiLo generators work or simply try it


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:04 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Actually Kramer is true for 0 and 1
But give it a try with 5 for example. The point is to increment a counter wo having to request the DB every time. Tthere may be holes in your sequence however

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 6:26 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Actually, the hilo generator always generates max_lo+1 values before fetching another hi value. The code is :
Code:
if (lo>maxLo)
{
    int hival = getNext(session);
    lo = (hival == 0) ? 1 : 0;
    hi = hival * (maxLo+1);
    LOGGER.debug("new hi value: " + hival);
}


I don't understand why the code is like this. The code below works as expected, it generates max_lo values before fetching a hi one.

Is there something I miss that explains why the code is like it is or not ?

Code:
if (lo>maxLo)
{
    int hival = getNext(session);
    lo = 1;
    hi = hival * (maxLo);
    LOGGER.debug("new hi value: " + hival);
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 5:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Double ckeck, the actual code fix the hole we were talking in this thread. Gavin an I changed it a couple of months ago

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 4:40 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
I double checked,

With the code in the 3.0rc1 version, if you give a maxlo of 0, you have a step of 1 and you have twice the 1 value.
It you have a value of 1 for maxlo, you have a step of 2 between each hi value.

There is only a problem with a 0 value for maxlo. The most disturbing thing is that the step between each hi value is maxlo + 1. With the actual code it is not possible to have a step of 1.

Maybe I am wrong because I do not use the 3.0 branch but I copy/paste the code for a custom generator in the 2.1 version. I have changed the code with the one I supplied in my previous post and now my step between each hi value is maxlo.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 5:50 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
maxlo of 0 is not revelant.
maxlo of 1 mean retrieve the value from the Table every time, basically a TableGenerator.

The algorithm currently work for maxLo >= 2

_________________
Emmanuel


Top
 Profile  
 
 Post subject: hilo
PostPosted: Mon Apr 09, 2007 10:56 am 
Newbie

Joined: Mon Apr 09, 2007 10:44 am
Posts: 2
Hi,

I have a couple of tables that use the same table to get the hilo sequence generator number for its ID column. The underlying db is AS400. All of them have it defined like this:

<id name="id" type="java.lang.Integer" unsaved-value="0">
<column name="XXCOLACID" sql-type="decimal(7,0)" not-null="true"/>
<generator class="hilo">
<param name="table">PFXXXSEQ</param>
<param name="column">NXTVAL</param>
<param name="max_lo">100</param>
</generator>
</id>

I get the following error very frequently. Many times when one of the batch jobs is in the middle of doing a lot of delete/inserts in one of the tables.

[4/9/07 10:12:46:288 EDT] 1d73e5f3 TableGenerato E org.hibernate.id.TableGenerator could not read a hi value
[4/9/07 10:12:46:319 EDT] 1d73e5f3 TableGenerato E org.hibernate.id.TableGenerator TRAS0014I: The following exception was logged java.sql.SQLException: [SQL0913] Row or object PFXXXSEQ in DATA type *FILE in use.


Should I keep the 'max_lo' field high or low for this? Or different for different tables?

Is hilo not supposed to be used by many different tables at the same time.

Any other setting in hibernate or database I am missing?

Thanks!


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

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.