Batch loading the same EntityKey (one side of manytoone ) more than once

Description

Within the same session, the same entity gets batch loaded multiple times. The ManyToOneType.scheduleBatchLoad calls BatchFetchQueue.addBatchLoadableEntityKey without checking to see if the entity already exists with the current PersistanceContext. Adding the extra condition "!context.containsEntity(key)" to the BatchFetchQueue.addBatchLoadableEntityKey method which seems to address the issue.

public void addBatchLoadableEntityKey(EntityKey key) {
if ( key.isBatchLoadable() && !context.containsEntity(key) ) {
batchLoadableEntityKeys.put(key, MARKER);
}
}

This will save few loops if we have large set of Entity being lodaded with each of them having manytoone relationship with other Entity.

Environment

None

Assignee

Steve Ebersole

Reporter

amit bhayani

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure