-->
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.  [ 2 posts ] 
Author Message
 Post subject: Child object is not deleted when removed from collection
PostPosted: Wed Jan 18, 2006 8:02 pm 
Newbie

Joined: Wed Jan 18, 2006 7:30 pm
Posts: 4
I have a problem working with detached objects, in that in certain circumstances child objects (in collections) that should be removed are not being removed when the detached object is reattached.

Here's what I do:
- in the database there is a parent object (id=1) and a child object(id=2)
- I load the parent, then close the session
- I open another session, create two new children and add them to the parent
- I call saveOrUpdate(parent) to attach the parent object to this session, which causes the two new children to be written to the database
- I then remove the original child object from the collection plus one of the new child objects
- close the session

The result is that the original child object is correctly deleted, but the other child object, that I attached and then removed in the second session, is not deleted.

If I move the saveOrUpdate(parent) so that it occurs at the start of the second session, or right at the end, all is well. The problem occurs if it's after the new child is attached to the parent but before it's removed.

If anyone can explain what's going on here I'd be grateful so that I can better understand the rules for working with detached objects.

Many thanks,
Patrick


Hibernate version:
3.1

Mapping documents:
Code:
<class name="com.ilign.hibernatetest.Parent" table="PARENT">

    <id name="objectId" column="PARENT_ID" type="long">
        <generator class="hilo">
            <param name="table">OBJECT_ID</param>
            <param name="column">next_value</param>
            <param name="max_lo">100</param>
        </generator>
    </id>

    <version name="vsn" column="VSN" type="integer"/>

    <property name="name" column="NAME" type="string" access="field"/>

    <set name="children" table="CHILD" lazy="false" cascade="all-delete-orphan" access="field">
        <key column="PARENT_ID" update="false"/>
        <one-to-many class="com.ilign.hibernatetest.Child"/>
    </set>

</class>

<class name="com.ilign.hibernatetest.Child" table="CHILD">

    <id name="objectId" column="CHILD_ID" type="long">
        <generator class="hilo">
            <param name="table">OBJECT_ID</param>
            <param name="column">next_value</param>
            <param name="max_lo">100</param>
        </generator>
    </id>

    <version name="vsn" column="VSN" type="integer"/>

    <property name="name" column="NAME" type="string" access="field"/>
    <many-to-one name="parent" column="PARENT_ID" cascade="none"/>

</class>


Code between sessionFactory.openSession() and session.close():
Code:
Session     session = factory.openSession();
Transaction tx      = session.beginTransaction();

Parent parent = (Parent) session.get( Parent.class, 1L );

tx.commit();
session.close();

session = factory.openSession();
tx      = session.beginTransaction();

Child child1 = parent.children.iterator().next();

Child child2 = new Child();
child2.setName( "child 2" );
child2.setParent( parent );

Child child3 = new Child();
child3.setName( "child 3" );
child3.setParent( parent );

parent.children.add( child2 );
parent.children.add( child3 );

session.saveOrUpdate( parent );

parent.children.remove( child1 );
parent.children.remove( child3 );

tx.commit();
session.close();


Full stack trace of any exception that occurs:

Name and version of the database you are using:
Firebird, version: WI-V6.3.2.4731 Firebird 1.5

The generated SQL (show_sql=true):
Hibernate: select parent0_.PARENT_ID as PARENT1_0_0_, parent0_.VSN as VSN0_0_, parent0_.NAME as NAME0_0_ from PARENT parent0_ where parent0_.PARENT_ID=?
Hibernate: select children0_.PARENT_ID as PARENT4_1_, children0_.CHILD_ID as CHILD1_1_, children0_.CHILD_ID as CHILD1_1_0_, children0_.VSN as VSN1_0_, children0_.NAME as NAME1_0_, children0_.PARENT_ID as PARENT4_1_0_ from CHILD children0_ where children0_.PARENT_ID=?
Hibernate: insert into CHILD (VSN, NAME, PARENT_ID, CHILD_ID) values (?, ?, ?, ?)
Hibernate: insert into CHILD (VSN, NAME, PARENT_ID, CHILD_ID) values (?, ?, ?, ?)
Hibernate: update PARENT set VSN=?, NAME=? where PARENT_ID=? and VSN=?
Hibernate: update CHILD set VSN=?, NAME=?, PARENT_ID=? where CHILD_ID=? and VSN=?
Hibernate: delete from CHILD where CHILD_ID=? and VSN=?

Debug level Hibernate log excerpt:
2006-01-19 12:20:19,868 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11376264198
2006-01-19 12:20:19,868 DEBUG [org.hibernate.transaction.JDBCTransaction] begin
2006-01-19 12:20:19,868 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-01-19 12:20:19,868 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] total checked-out connections: 0
2006-01-19 12:20:19,868 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] using pooled JDBC connection, pool size: 0
2006-01-19 12:20:19,868 DEBUG [org.hibernate.transaction.JDBCTransaction] current autocommit status: false
2006-01-19 12:20:19,868 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction begin
2006-01-19 12:20:19,868 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] loading entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,868 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] attempting to resolve: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,868 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] object not resolved in any cache: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,868 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Fetching entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,868 DEBUG [org.hibernate.loader.Loader] loading entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,868 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:19,868 DEBUG [org.hibernate.SQL] select parent0_.PARENT_ID as PARENT1_0_0_, parent0_.VSN as VSN0_0_, parent0_.NAME as NAME0_0_ from PARENT parent0_ where parent0_.PARENT_ID=?
2006-01-19 12:20:19,868 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:19,915 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-01-19 12:20:19,915 DEBUG [org.hibernate.loader.Loader] processing result set
2006-01-19 12:20:19,915 DEBUG [org.hibernate.loader.Loader] result set row: 0
2006-01-19 12:20:19,915 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,915 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,915 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Hydrating entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,931 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 0
2006-01-19 12:20:19,931 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2006-01-19 12:20:19,931 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-01-19 12:20:19,931 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:19,931 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:19,931 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2006-01-19 12:20:19,931 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.engine.CollectionLoadContext] creating collection wrapper:[com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
2006-01-19 12:20:19,947 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] initializing collection [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] checking second-level cache
2006-01-19 12:20:19,947 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] collection not cached
2006-01-19 12:20:19,947 DEBUG [org.hibernate.loader.Loader] loading collection: [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:19,947 DEBUG [org.hibernate.SQL] select children0_.PARENT_ID as PARENT4_1_, children0_.CHILD_ID as CHILD1_1_, children0_.CHILD_ID as CHILD1_1_0_, children0_.VSN as VSN1_0_, children0_.NAME as NAME1_0_, children0_.PARENT_ID as PARENT4_1_0_ from CHILD children0_ where children0_.PARENT_ID=?
2006-01-19 12:20:19,947 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:19,947 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-01-19 12:20:19,947 DEBUG [org.hibernate.loader.Loader] result set contains (possibly empty) collection: [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,947 DEBUG [org.hibernate.engine.CollectionLoadContext] uninitialized collection: initializing
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] processing result set
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] result set row: 0
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] result row: EntityKey[com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] Initializing object from ResultSet: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Hydrating entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.TwoPhaseLoad] Version: 0
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] found row of collection: [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.CollectionLoadContext] reading row
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] loading entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] attempting to resolve: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] resolved object in session cache: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] done processing result set (1 rows)
2006-01-19 12:20:19,962 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-01-19 12:20:19,962 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:19,962 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 1
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.TwoPhaseLoad] resolving associations for [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] loading entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultLoadEventListener] entity found in session cache
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.CollectionLoadContext] 1 collections were found in result set for role: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.CollectionLoadContext] collection fully initialized: [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.CollectionLoadContext] 1 collections initialized for role: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] done loading collection
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultInitializeCollectionEventListener] collection initialized

2006-01-19 12:20:19,962 DEBUG [org.hibernate.loader.Loader] done entity load
2006-01-19 12:20:19,962 DEBUG [org.hibernate.transaction.JDBCTransaction] commit
2006-01-19 12:20:19,962 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.CascadingAction] cascading to saveOrUpdate: com.ilign.hibernatetest.Child
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] persistent instance of: com.ilign.hibernatetest.Child
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] ignoring persistent instance
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] object already associated with session: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] done deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,962 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:19,962 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushing entities and processing referenced collections
2006-01-19 12:20:19,978 DEBUG [org.hibernate.engine.Collections] Collection found: [com.ilign.hibernatetest.Parent.children#1], was: [com.ilign.hibernatetest.Parent.children#1] (initialized)
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Processing unreferenced collections
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 insertions, 0 updates, 0 deletions to 2 objects
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
2006-01-19 12:20:19,978 DEBUG [org.hibernate.pretty.Printer] listing entities:
2006-01-19 12:20:19,978 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Parent{vsn=0, objectId=1, name=parent 1, children=[com.ilign.hibernatetest.Child#2]}
2006-01-19 12:20:19,978 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Child{vsn=0, objectId=2, name=child 1, parent=com.ilign.hibernatetest.Parent#1}
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] executing flush
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] post flush
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2006-01-19 12:20:19,978 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2006-01-19 12:20:19,978 DEBUG [org.hibernate.transaction.JDBCTransaction] committed JDBC Connection
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-01-19 12:20:19,978 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] returning connection to pool, pool size: 1
2006-01-19 12:20:19,978 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2006-01-19 12:20:19,978 DEBUG [org.hibernate.impl.SessionImpl] closing session
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action
2006-01-19 12:20:19,978 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 11376264199
2006-01-19 12:20:19,978 DEBUG [org.hibernate.transaction.JDBCTransaction] begin
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-01-19 12:20:19,978 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] total checked-out connections: 0
2006-01-19 12:20:19,978 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] using pooled JDBC connection, pool size: 0
2006-01-19 12:20:19,978 DEBUG [org.hibernate.transaction.JDBCTransaction] current autocommit status: false
2006-01-19 12:20:19,978 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction begin
2006-01-19 12:20:19,978 DEBUG [org.hibernate.engine.VersionValue] version unsaved-value strategy UNDEFINED
2006-01-19 12:20:19,978 DEBUG [org.hibernate.engine.IdentifierValue] id unsaved-value: null
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] detached instance of: com.ilign.hibernatetest.Parent
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating detached instance
2006-01-19 12:20:19,978 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,993 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:19,993 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:19,993 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:19,993 DEBUG [org.hibernate.engine.CascadingAction] cascading to saveOrUpdate: com.ilign.hibernatetest.Child
2006-01-19 12:20:19,993 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] transient instance of: com.ilign.hibernatetest.Child
2006-01-19 12:20:19,993 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] saving transient instance
2006-01-19 12:20:19,993 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2006-01-19 12:20:19,993 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] total checked-out connections: 1
2006-01-19 12:20:19,993 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] opening new JDBC connection
2006-01-19 12:20:19,993 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] created connection to: jdbc:firebirdsql://localhost:3050/c:/devtools/firebird/ilign.fdb, Isolation Level: 2
2006-01-19 12:20:19,993 DEBUG [org.hibernate.SQL] select next_value from OBJECT_ID with lock
2006-01-19 12:20:19,993 DEBUG [org.hibernate.SQL] update OBJECT_ID set next_value = ? where next_value = ?
2006-01-19 12:20:19,993 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
2006-01-19 12:20:19,993 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] returning connection to pool, pool size: 1
2006-01-19 12:20:19,993 DEBUG [org.hibernate.id.TableHiLoGenerator] new hi value: 100040
2006-01-19 12:20:19,993 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 10104040, using strategy: org.hibernate.id.TableHiLoGenerator
2006-01-19 12:20:19,993 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [com.ilign.hibernatetest.Child#10104040]
2006-01-19 12:20:19,993 DEBUG [org.hibernate.engine.Versioning] using initial version: 0
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.CascadingAction] cascading to saveOrUpdate: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.VersionValue] version unsaved-value strategy UNDEFINED
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.IdentifierValue] id unsaved-value: null
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] detached instance of: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating detached instance
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.CascadingAction] cascading to saveOrUpdate: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] transient instance of: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] saving transient instance
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 10104041, using strategy: org.hibernate.id.TableHiLoGenerator
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [com.ilign.hibernatetest.Child#10104041]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Versioning] using initial version: 0
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:20,009 DEBUG [org.hibernate.transaction.JDBCTransaction] commit
2006-01-19 12:20:20,009 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.CascadingAction] cascading to saveOrUpdate: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] persistent instance of: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] ignoring persistent instance
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] object already associated with session: [com.ilign.hibernatetest.Child#10104041]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done cascade ACTION_SAVE_UPDATE for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] deleting orphaned entity instance: com.ilign.hibernatetest.Child
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultDeleteEventListener] deleting a persistent instance
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultDeleteEventListener] deleting [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.impl.SessionImpl] setting cache mode to: GET
2006-01-19 12:20:20,009 DEBUG [org.hibernate.impl.SessionImpl] setting cache mode to: NORMAL
2006-01-19 12:20:20,009 DEBUG [org.hibernate.impl.SessionImpl] setting cache mode to: GET
2006-01-19 12:20:20,009 DEBUG [org.hibernate.impl.SessionImpl] setting cache mode to: NORMAL
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done deleting orphans for collection: com.ilign.hibernatetest.Parent.children
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Cascade] done processing cascade ACTION_SAVE_UPDATE for: com.ilign.hibernatetest.Parent
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.CollectionEntry] Collection dirty: [com.ilign.hibernatetest.Parent.children#1]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushing entities and processing referenced collections
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultFlushEntityEventListener] Updating entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Versioning] Incrementing: 0 to 1
2006-01-19 12:20:20,009 DEBUG [org.hibernate.engine.Collections] Collection found: [com.ilign.hibernatetest.Parent.children#1], was: [com.ilign.hibernatetest.Parent.children#1] (initialized)
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.DefaultFlushEntityEventListener] Updating deleted entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Processing unreferenced collections
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 2 insertions, 2 updates, 1 deletions to 4 objects
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 0 (re)creations, 1 updates, 0 removals to 1 collections
2006-01-19 12:20:20,009 DEBUG [org.hibernate.pretty.Printer] listing entities:
2006-01-19 12:20:20,009 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Child{vsn=0, objectId=10104040, name=child 3, parent=com.ilign.hibernatetest.Parent#1}
2006-01-19 12:20:20,009 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Parent{vsn=0, objectId=1, name=parent 1, children=[com.ilign.hibernatetest.Child#10104041]}
2006-01-19 12:20:20,009 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Child{vsn=0, objectId=10104041, name=child 2, parent=com.ilign.hibernatetest.Parent#1}
2006-01-19 12:20:20,009 DEBUG [org.hibernate.pretty.Printer] com.ilign.hibernatetest.Child{vsn=0, objectId=2, name=child 1, parent=com.ilign.hibernatetest.Parent#1}
2006-01-19 12:20:20,009 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] executing flush
2006-01-19 12:20:20,009 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Inserting entity: [com.ilign.hibernatetest.Child#10104040]
2006-01-19 12:20:20,009 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Version: 0
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.SQL] insert into CHILD (VSN, NAME, PARENT_ID, CHILD_ID) values (?, ?, ?, ?)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Dehydrating entity: [com.ilign.hibernatetest.Child#10104040]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Inserting entity: [com.ilign.hibernatetest.Child#10104041]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Version: 0
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] reusing prepared statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.SQL] insert into CHILD (VSN, NAME, PARENT_ID, CHILD_ID) values (?, ?, ?, ?)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Dehydrating entity: [com.ilign.hibernatetest.Child#10104041]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Updating entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Existing version: 0 -> New version: 1
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.SQL] update PARENT set VSN=?, NAME=? where PARENT_ID=? and VSN=?
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Dehydrating entity: [com.ilign.hibernatetest.Parent#1]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Updating entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Existing version: 0 -> New version: 0
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.SQL] update CHILD set VSN=?, NAME=?, PARENT_ID=? where CHILD_ID=? and VSN=?
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Dehydrating entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Deleting entity: [com.ilign.hibernatetest.Child#2]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.persister.entity.AbstractEntityPersister] Version: 0
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.SQL] delete from CHILD where CHILD_ID=? and VSN=?
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2006-01-19 12:20:20,025 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] post flush
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2006-01-19 12:20:20,025 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2006-01-19 12:20:20,025 DEBUG [org.hibernate.transaction.JDBCTransaction] committed JDBC Connection
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-01-19 12:20:20,025 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] closing JDBC connection
2006-01-19 12:20:20,025 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2006-01-19 12:20:20,025 DEBUG [org.hibernate.impl.SessionImpl] closing session
2006-01-19 12:20:20,025 DEBUG [org.hibernate.jdbc.ConnectionManager] connection already null in cleanup : no action

Code:


Top
 Profile  
 
 Post subject: Problem of generator class and association
PostPosted: Thu Jan 19, 2006 5:58 am 
Newbie

Joined: Sat Sep 24, 2005 12:24 pm
Posts: 7
Possible the same problem I have:
I found out that when I create an object and add it to the collection before the id is created from hibernate it will be inserted with another key into the set (depends how you implemented the hashCode() methode.
When you save the child object before than everything is correct. Or another workaround (in our testcase) is to call Session.clear()

regards,
Juergen


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