-->
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: Strange identity generation hsqldb
PostPosted: Thu Jul 29, 2004 5:22 am 
Regular
Regular

Joined: Tue Jan 27, 2004 12:22 pm
Posts: 103
Hello forum,

Hibernate version: Hibernate 2.1.4
Java version used: 1.4.2_05
HSQLDB used: HSQLDB server 1.7.1

Problem:
I have one Class Dossier which has a list of Order objects. When I save a Dossier instance, I see that every instance in the order list get's a identity assigned, but the identity skips one position. So instead of assigning, 0,1,2,3 as ID to the Order instances it assigns 0,2,4,6.
I've checked the debug output, but as far as I can see there's no deletion of any objects, it simply skips one identity value.

Mapping files (Dossier/Order):
Dossier:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="nl.dgoexpress.vikie.bbo">

<class name="Dossier" table="dossiers">
<id name="id" type="int" column="id" unsaved-value="-1">
<generator class="identity"/>
</id>

<many-to-one name="customer" class="Customer" column="customerid"/>
<property name="date" type="calendar"/>
<property name="reference" type="string"/>

<property name="senddate" type="calendar"/>

<property name="orderCount" type="int"/>

<list name="orders" table="orders" cascade="all-delete-orphan" lazy="true">
<key column="dossierid"/>
<index column="listindex"/>
<one-to-many class="Order"/>
</list>
</class>
</hibernate-mapping>

Order:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping default-cascade="none" package="nl.dgoexpress.vikie.bbo">

<class name="Order" table="orders">
<id name="id" type="int" column="id" unsaved-value="-1">
<generator class="identity"/>
</id>

<property name="orderDate" type="calendar"/>

<many-to-one name="dossier" class="Dossier" column="dossierid"/>

<many-to-one name="collectAddress" class="Address" column="collectaddressid" cascade="save-update"/>
<property name="collectFrom" type="calendar"/>
<property name="collectTill" type="calendar"/>
<property name="collectReference" type="string"/>

<many-to-one name="deliverAddress" class="Address" column="deliveraddressid" cascade="save-update"/>
<property name="deliverFrom" type="calendar"/>
<property name="deliverTill" type="calendar"/>
<property name="deliverReference" type="string"/>

<property name="totalReimburs" type="double"/>
<property name="totalAmount" type="double"/>
<property name="totalWeight" type="double"/>

<property name="reference" type="string"/>
<property name="comments" type="string"/>

<list name="orderDetails" table="orderdetails" cascade="all-delete-orphan">
<key column="orderid"/>
<index column="listindex"/>
<one-to-many class="OrderDetail"/>
</list>
</class>
</hibernate-mapping>

Output debug:
[java] 11:22:15,805 DEBUG JDBCTransaction:37 - begin
[java] 11:22:15,815 DEBUG JDBCTransaction:41 - current autocommit status:false
[java] 11:22:15,815 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
[java] 11:22:15,815 DEBUG JDBCTransaction:59 - commit
[java] 11:22:15,815 DEBUG SessionImpl:2242 - flushing session
[java] 11:22:15,815 DEBUG Cascades:497 - processing cascades for: nl.dgoexpress.vikie.bbo.Dossier
[java] 11:22:15,815 DEBUG Cascades:524 - cascading to collection: nl.dgoexpress.vikie.bbo.Dossier.orders
[java] 11:22:15,815 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,825 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
[java] 11:22:15,825 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,825 DEBUG Cascades:312 - id unsaved-value: -1
[java] 11:22:15,825 DEBUG SessionImpl:1386 - saveOrUpdate() unsaved instance
[java] 11:22:15,825 DEBUG SessionImpl:825 - saving [nl.dgoexpress.vikie.bbo.Order#<null>]
[java] 11:22:15,835 DEBUG SessionImpl:2305 - executing insertions
[java] 11:22:15,835 DEBUG Cascades:497 - processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,835 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,835 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
[java] 11:22:15,835 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,845 DEBUG Cascades:312 - id unsaved-value: -1
[java] 11:22:15,875 DEBUG SessionImpl:1386 - saveOrUpdate() unsaved instance
[java] 11:22:15,875 DEBUG SessionImpl:825 - saving [nl.dgoexpress.vikie.bbo.Address#<null>]
[java] 11:22:15,885 DEBUG SessionImpl:2305 - executing insertions
[java] 11:22:15,885 DEBUG EntityPersister:490 - Inserting entity: nl.dgoexpress.vikie.bbo.Address (native id)
[java] 11:22:15,885 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,885 DEBUG SQL:237 - insert into Addresses (parentid, searchCode, name, address, zipcode, city, contact, countryid, telephoneNumber, deleted, temporary, collectFrom, collectTill, deliverFrom, deliverTill, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)
[java] Hibernate: insert into Addresses (parentid, searchCode, name, address, zipcode, city, contact, countryid, telephoneNumber, deleted, temporary, collectFrom, collectTill, deliverFrom, deliverTill, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)
[java] 11:22:15,885 DEBUG BatcherImpl:241 - preparing statement
[java] 11:22:15,895 DEBUG EntityPersister:388 - Dehydrating entity: [nl.dgoexpress.vikie.bbo.Address#<null>]
[java] 11:22:15,895 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,895 DEBUG BatcherImpl:261 - closing statement
[java] 11:22:15,895 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,895 DEBUG SQL:237 - CALL IDENTITY()
[java] Hibernate: CALL IDENTITY()
[java] 11:22:15,905 DEBUG BatcherImpl:241 - preparing statement
[java] 11:22:15,905 DEBUG AbstractEntityPersister:1229 - Natively generated identity: 3
[java] 11:22:15,905 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,905 DEBUG BatcherImpl:261 - closing statement
[java] 11:22:15,905 DEBUG Cascades:506 - done processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,905 DEBUG WrapVisitor:81 - Wrapped collection in role: nl.dgoexpress.vikie.bbo.Order.orderDetails
[java] 11:22:15,915 DEBUG EntityPersister:490 - Inserting entity: nl.dgoexpress.vikie.bbo.Order (native id)
[java] 11:22:15,915 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,915 DEBUG SQL:237 - insert into orders (orderDate, dossierid, collectaddressid, collectFrom, collectTill, collectReference, deliveraddressid, deliverFrom, deliverTill, deliverReference, totalReimburs, totalAmount, totalWeight, reference, comments, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)
[java] Hibernate: insert into orders (orderDate, dossierid, collectaddressid, collectFrom, collectTill, collectReference, deliveraddressid, deliverFrom, deliverTill, deliverReference, totalReimburs, totalAmount, totalWeight, reference, comments, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, null)
[java] 11:22:15,925 DEBUG BatcherImpl:241 - preparing statement
[java] 11:22:15,925 DEBUG EntityPersister:388 - Dehydrating entity: [nl.dgoexpress.vikie.bbo.Order#<null>]
[java] 11:22:15,925 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,925 DEBUG BatcherImpl:261 - closing statement
[java] 11:22:15,935 DEBUG BatcherImpl:196 - about to open: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,935 DEBUG SQL:237 - CALL IDENTITY()
[java] Hibernate: CALL IDENTITY()
[java] 11:22:15,935 DEBUG BatcherImpl:241 - preparing statement
[java] 11:22:15,935 DEBUG AbstractEntityPersister:1229 - Natively generated identity: 2
[java] 11:22:15,935 DEBUG BatcherImpl:203 - done closing: 0 open PreparedStatements, 0 open ResultSets
[java] 11:22:15,935 DEBUG BatcherImpl:261 - closing statement
[java] 11:22:15,945 DEBUG Cascades:497 - processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,945 DEBUG Cascades:524 - cascading to collection: nl.dgoexpress.vikie.bbo.Order.orderDetails
[java] 11:22:15,945 DEBUG Cascades:506 - done processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,945 DEBUG Cascades:506 - done processing cascades for: nl.dgoexpress.vikie.bbo.Dossier
[java] 11:22:15,945 DEBUG Cascades:497 - processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,945 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,945 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
[java] 11:22:15,955 DEBUG Cascades:113 - cascading to saveOrUpdate()
[java] 11:22:15,955 DEBUG SessionImpl:1371 - saveOrUpdate() persistent instance
[java] 11:22:15,955 DEBUG Cascades:524 - cascading to collection: nl.dgoexpress.vikie.bbo.Order.orderDetails
[java] 11:22:15,955 DEBUG Cascades:506 - done processing cascades for: nl.dgoexpress.vikie.bbo.Order
[java] 11:22:15,955 DEBUG SessionImpl:342 - Collection dirty: [nl.dgoexpress.vikie.bbo.Dossier.orders#0]
[java] 11:22:15,955 DEBUG SessionImpl:2435 - Flushing entities and processing referenced collections
[java] 11:22:15,975 DEBUG AbstractEntityPersister:274 - nl.dgoexpress.vikie.bbo.Dossier.orderCount is dirty
[java] 11:22:15,975 DEBUG SessionImpl:2529 - Updating entity: [nl.dgoexpress.vikie.bbo.Dossier#0]
[java] 11:22:15,975 DEBUG SessionImpl:2880 - Collection found: [nl.dgoexpress.vikie.bbo.Dossier.orders#0], was: [nl.dgoexpress.vikie.bbo.Dossier.orders#0]
[java] 11:22:15,975 DEBUG SessionImpl:2880 - Collection found: [nl.dgoexpress.vikie.bbo.Order.orderDetails#0], was: [nl.dgoexpress.vikie.bbo.Order.orderDetails#0]
[java] 11:22:15,975 DEBUG SessionImpl:2880 - Collection found: [nl.dgoexpress.vikie.bbo.Order.orderDetails#2], was: [<unreferenced>]
[java] 11:22:15,975 DEBUG SessionImpl:2776 - Processing unreferenced collections
[java] 11:22:16,005 DEBUG SessionImpl:2790 - Scheduling collection removes/(re)creates/updates
[java] 11:22:16,015 DEBUG SessionImpl:2266 - Flushed: 0 insertions, 1 updates, 0 deletions to 19 objects
[java] 11:22:16,015 DEBUG SessionImpl:2271 - Flushed: 1 (re)creations, 1 updates, 0 removals to 3 collections
[java] 11:22:16,015 DEBUG Printer:75 - listing entities:
[java] 11:22:16,015 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Country{abbreviation=DE, formatZipcode=######, standard=false, countryCode=49, name=Duitsland, id=1}
[java] 11:22:16,015 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Unit{defaultLength=0, abbreviation=EURO, category=UnitCategory#0, numOfUnitsOnParent=0, id=0, parentUnit=null, defaultVolume=0.0, defaultHeight=0, unitWeight=0.0, defaultLoadmeters=0.0, defaultWidth=0, defaultWeight=300.0, defaultUnit=false, name=Euro pallets, defaultPalletPlaces=0.0}
[java] 11:22:16,025 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Order{comments=, orderDetails=[], collectTill=null, deliverReference=null, deliverFrom=null, deliverTill=null, id=0, totalAmount=0.0, totalWeight=0.0, collectFrom=null, dossier=Dossier#0, totalReimburs=0.0, orderDate=29 juli 2004 00:00:00, collectReference=null, collectAddress=Address#0, deliverAddress=Address#2, reference=}
[java] 11:22:16,025 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Customer{debid=12345, message=null, address=Address#1, customerid=1}
[java] 11:22:16,025 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Country{abbreviation=NL, formatZipcode=#### XX, standard=true, countryCode=31, name=Nederland, id=0}
[java] 11:22:16,025 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Dossier{senddate=null, orders=[Order#0, Order#2], orderCount=2, customer=Customer#0, date=29 juli 2004 11:22:13, id=0, reference=null}
[java] 11:22:16,025 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Order{comments=, orderDetails=[], collectTill=null, deliverReference=null, deliverFrom=null, deliverTill=null, id=2, totalAmount=0.0, totalWeight=0.0, collectFrom=null, dossier=Dossier#0, totalReimburs=0.0, orderDate=29 juli 2004 00:00:00, collectReference=null, collectAddress=Address#0, deliverAddress=Address#3, reference=}
[java] 11:22:16,035 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Customer{debid=123456, message=null, address=Address#0, customerid=0}
[java] 11:22:16,035 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Address{deleted=false, collectTill=null, address=Teststraat 19, searchCode=TEST, deliverFrom=null, deliverTill=null, id=0, contact=null, country=Country#0, temporary=false, collectFrom=null, parentid=0, name=Test bedrijf, telephoneNumber=null, zipcode=1234 AB, city=TestDorp}
[java] 11:22:16,035 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Country{abbreviation=FR, formatZipcode=xxx, standard=false, countryCode=45, name=Frankrijk, id=4}
[java] 11:22:16,035 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.UnitCategory{code=0, abbreviation=PALL, description=null, name=Pallets, id=0}
[java] 11:22:16,035 DEBUG Printer:82 - nl.dgoexpress.vikie.bbo.Country{abbreviation=BE, formatZipcode=xxx, standard=false, countryCode=33, name=Belgi

_________________
Dencel
- The sun has never seen a shadow -


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.