We're updating the issue view to help you get more done. 

Perfomance issue with ElementCollection

Description

We have issue with perfomance of updating map collection under heavy load. Our collection mapping:

@ElementCollection
@MapKeyJoinColumn( name = "poi", nullable = false )
@JoinTable( name = "mon_race_poi_arrival",
joinColumns = {
@JoinColumn( name = "workday", nullable = false, referencedColumnName = "workday" ),
@JoinColumn( name = "date_execute", nullable = false, referencedColumnName = "dateExecute" ),
@JoinColumn( name = "race_number", nullable = false, referencedColumnName = "raceNumber" )
} )
private Map<Poi, PoiArrival> poiArrival;

For workarounding you are always recreate collection if there is no not null property in collection element (methods org.hibernate.action.internal.CollectionUpdateAction#execute and org.hibernate.collection.internal.AbstractPersistentCollection#needsRecreate).

But if there is indexed collection (list or map), this recreation can be avoided, because index property is usualy is not null, and it is used in where condition for updates instead of element values.

Fixing this can be easy - just override method needsRecreate in PersistentMap and PersistentList, like you are already do in PersistentBag.
Or rewrite common method in AbstractPersistentCollection to check nullability of index column.

Environment

None

Status

Assignee

Sergey Astakhov

Reporter

Sergey Astakhov

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.3.7

Priority

Major