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 encounteredName and version of the database you are using:Oracle 10 somethingThe 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