HHH-9455 : Unnecessary select count query in some cases
(cherry picked from commit552c1c06d5
) (cherry picked from commit460e966214
)
This commit is contained in:
parent
b197f6a643
commit
e2de2a6fcf
|
@ -1766,8 +1766,7 @@ public abstract class AbstractCollectionPersister
|
||||||
public void processQueuedOps(PersistentCollection collection, Serializable key, SessionImplementor session)
|
public void processQueuedOps(PersistentCollection collection, Serializable key, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
if ( collection.hasQueuedOperations() ) {
|
if ( collection.hasQueuedOperations() ) {
|
||||||
int nextIndex = getSize( key, session );
|
doProcessQueuedOps( collection, key, session );
|
||||||
doProcessQueuedOps( collection, key, nextIndex, session );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,28 +195,33 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
public void recreate(PersistentCollection collection, Serializable id, SessionImplementor session)
|
public void recreate(PersistentCollection collection, Serializable id, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
super.recreate( collection, id, session );
|
super.recreate( collection, id, session );
|
||||||
writeIndex( collection, collection.entries( this ), id, 0, session );
|
writeIndex( collection, collection.entries( this ), id, true, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertRows(PersistentCollection collection, Serializable id, SessionImplementor session)
|
public void insertRows(PersistentCollection collection, Serializable id, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
super.insertRows( collection, id, session );
|
super.insertRows( collection, id, session );
|
||||||
writeIndex( collection, collection.entries( this ), id, 0, session );
|
writeIndex( collection, collection.entries( this ), id, true, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doProcessQueuedOps(PersistentCollection collection, Serializable id, SessionImplementor session)
|
protected void doProcessQueuedOps(PersistentCollection collection, Serializable id, SessionImplementor session)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
writeIndex( collection, collection.queuedAdditionIterator(), id, getSize( id, session ), session );
|
writeIndex( collection, collection.queuedAdditionIterator(), id, false, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeIndex(PersistentCollection collection, Iterator entries, Serializable id,
|
private void writeIndex(
|
||||||
int nextIndex, SessionImplementor session) {
|
PersistentCollection collection,
|
||||||
|
Iterator entries,
|
||||||
|
Serializable id,
|
||||||
|
boolean resetIndex,
|
||||||
|
SessionImplementor session) {
|
||||||
// If one-to-many and inverse, still need to create the index. See HHH-5732.
|
// If one-to-many and inverse, still need to create the index. See HHH-5732.
|
||||||
if ( isInverse && hasIndex && !indexContainsFormula ) {
|
if ( isInverse && hasIndex && !indexContainsFormula ) {
|
||||||
try {
|
try {
|
||||||
if ( entries.hasNext() ) {
|
if ( entries.hasNext() ) {
|
||||||
|
int nextIndex = resetIndex ? 0 : getSize( id, session );
|
||||||
Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() );
|
Expectation expectation = Expectations.appropriateExpectation( getUpdateCheckStyle() );
|
||||||
while ( entries.hasNext() ) {
|
while ( entries.hasNext() ) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue