-->
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: Session flush doesn't persist objects to database
PostPosted: Thu Mar 22, 2007 3:46 pm 
Newbie

Joined: Thu Mar 22, 2007 3:27 pm
Posts: 3
I have some code to insert a collection of one type of objects (only one table is related). Because the size of the collection is very big, I need to flush the session sometimes for not causing OutOfMemory problem. Thus, there is session.flush() and session.clear() to do this.

However, this doesn't work because I have <generator class="hilo">. Then the insert() in class AbstractEntityPersister execute this:
...
else {
// For the case of dynamic-insert="false", use the static SQL
for ( int j = 0; j < span; j++ ) {
insert( id, fields, getPropertyInsertability(), j, getSQLInsertStrings()[j], object, session );
}
...

Then, this line of called
final boolean useBatch = j == 0 && !callable;
...
if ( useBatch ) {
session.getBatcher().addToBatch( 1 );
}

Since span is always 1 and j is always 0, no insertion is executed. This happens before I set "hibernate.jdbc.batch_size".

After I set the property, there is still no improvement. It failed at updateOrInsert() in AbstractEntityPersister -
...
else {
isRowToUpdate = update( id, fields, oldFields, rowId, includeProperty, j, oldVersion, object, sql, session );
}

if ( !isRowToUpdate && !isAllNull( fields, j ) ) {
insert( id, fields, getPropertyInsertability(), j, getSQLInsertStrings()[j], object, session );
}
...
The reason is isRowToUpdate always returns true, then no actual insert gets executed.

Is there a solution for this case?


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.