-->
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.  [ 3 posts ] 
Author Message
 Post subject: seqHiLo value not getting updated
PostPosted: Mon Aug 11, 2008 5:06 pm 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hi all,

Question - I'm using seqHiLo to generate the identifier keys on many of my tables. An example is a type TrAuditEventVO (info below) The sequence table defined in the mapping file exists and if I call next val I can successfully get the next identifier. Unfortunatly it is the wrong identifier as the max event_id is currently over 18 million but if I query the for the sequence via select j3_foundations_dba.tracked_event_seq.nextval from dual I get a value which is about 10 million less then the current max event_id. I realize it is not Hibernates job to update this seq to the next value (least I would expect it wouldn't be) I'm curious how Hibernate seems to be getting a correct next sequence but a direct query doesn't. This is based on Oracle Rac if that has anyting to do with it.

Any suggestions? We have a, non-hibernate based, app which needs to insert some data into the table using the next sequence id which is generally already used if we use the nextseq from dual concept. Is the current sequence being cached by Hibernate? Is my configuration incorrect?

Thanks in advance for any assistence!

Dave Ziebol
\|/

Hibernate version:3.1rc2

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping schema="j3_foundations_dba" package="com.thomson.west.foundations.traudit" default-cascade="all">
    <class name="TrAuditEventVO" table="tracked_event">
        <id name="eventId" column="event_id" type="long" unsaved-value="null">
            <!-- <generator class="increment"/>
         <generator class="sequence">-->
         <generator class="seqhilo">
               <param name="sequence">tracked_event_seq</param>
               <param name="maxlow">100</param>
           </generator>
        </id>
        <property name="trAuditTrackingId" type="string" column="tracking_uuid"/>
        <property name="appName" type="string" column="app_name"/>
        <property name="environment" type="string" column="environment_id"/>
        <property name="serverName" type="string" column="server_name"/>

        <property name="clientReceiptStamp" type="calendar" column="client_serv_rec_stamp" not-null="false"/>
        <property name="serverReceiptStamp" type="calendar" column="serv_rec_stamp" not-null="false"/>
        <property name="eventReceiptStamp" type="calendar" column="event_rec_stamp" not-null="false"/>
      <property name="perfByType" type="integer" column="perf_by_type"/>
      <property name="perfById" type="string" column="perf_by_id"/>
      <property name="perfById2" type="string" column="perf_by_id2"/>
     <!-- </component> -->

     <!-- setup the FoundationsOnWhat value -->
     <set name="onWhatSet" table="track_on_what" lazy="false" fetch="subselect" cascade="all" inverse="true">
      <key column="event_id"/>
      <one-to-many class="com.thomson.west.foundations.FoundationsOnWhatVO"/>
     </set>

     <!-- setup the eventTypeId value -->
     <many-to-one name="eventType" column="event_type_id" lazy="false" fetch="join" class="com.thomson.west.foundations.traudit.TrAuditEventTypeVO"/>

     <!-- setup the notesCollection value -->
     <set name="valuesCollect" table="tracked_value" fetch="subselect" lazy="false" cascade="all" inverse="true" >
       <key column="event_id"/>
      <one-to-many class="com.thomson.west.foundations.traudit.TrAuditValueVO"/>
     </set>
    
    </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:No exception encountered

Name and version of the database you are using:Oracle 10 something

The generated SQL (show_sql=true):
The insert prepared statement
Code:
insert into j3_foundations_dba.tracked_event (tracking_uuid, app_name, environment_id, server_name, client_serv_rec_stamp, serv_rec_stamp, event_rec_stamp, perf_by_type, perf_by_id, perf_by_id2, event_type_id, event_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

When the identifier is retrieved:
Code:
DEBUG org.hibernate.event.def.AbstractSaveEventListener  - generated identifier: 18902938, using strategy: org.hibernate.id.SequenceHiLoGenerator

The object being inserted (via pretty printer)
Code:
org.hibernate.pretty.Printer  - com.thomson.west.foundations.traudit.TrAuditEventVO{serverReceiptStamp=2008-08-11 15:40:29, perfById=, eventId=18902938, environment=serverSide, perfByType=2, appName=c... snipped irrelevent junk



Debug level Hibernate log excerpt:
It seems to get the correct value!
Code:
org.hibernate.pretty.Printer  - com.thomson.west.foundations.traudit.TrAuditEventVO{serverReceiptStamp=2008-08-11 15:40:29, perfById=, eventId=18902938, environment=serverSide, perfByType=2, appName=c

Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 11:11 am 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Question refinement - I guess.

Does seqhilo get sequence values from the specified table, or does it get a starting point from the table and then calculate sequence numbers based on the starting point?

The docs note:
Code:
An IdentifierGenerator that combines a hi/lo algorithm with an underlying oracle-style sequence that generates hi values. The user may specify a maximum lo value to determine how often new hi values are fetched.


so... does the algorithm calculate the next sequence number or does the table return a value?

If I need the value to come from the oracle sequence table, do I need to use Sequence rather then SequenceHiLo?

Thanks

Dave

_________________
Dave Ziebol


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 12, 2008 11:14 am 
Beginner
Beginner

Joined: Tue Sep 27, 2005 2:51 pm
Posts: 27
Question refinement - I guess.

Does seqhilo get sequence values from the specified table, or does it get a starting point from the table and then calculate sequence numbers based on the starting point?

The docs note:
Code:
An IdentifierGenerator that combines a hi/lo algorithm with an underlying oracle-style sequence that generates hi values. The user may specify a maximum lo value to determine how often new hi values are fetched.


so... does the algorithm calculate the next sequence number or does the table return a value?

If I need the value to come from the oracle sequence table, do I need to use Sequence rather then SequenceHiLo?

Thanks

Dave

_________________
Dave Ziebol


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.