Search in sources :

Example 1 with CollectionTracker

use of org.hibernate.bytecode.enhance.spi.CollectionTracker in project hibernate-orm by hibernate.

the class LazyAttributeLoadingInterceptor method takeCollectionSizeSnapshot.

// 
private void takeCollectionSizeSnapshot(Object target, String fieldName, Object value) {
    if (value != null && value instanceof Collection && target instanceof SelfDirtinessTracker) {
        CollectionTracker tracker = ((SelfDirtinessTracker) target).$$_hibernate_getCollectionTracker();
        if (tracker == null) {
            ((SelfDirtinessTracker) target).$$_hibernate_clearDirtyAttributes();
            tracker = ((SelfDirtinessTracker) target).$$_hibernate_getCollectionTracker();
        }
        tracker.add(fieldName, ((Collection) value).size());
    }
}
Also used : Collection(java.util.Collection) CollectionTracker(org.hibernate.bytecode.enhance.spi.CollectionTracker) SelfDirtinessTracker(org.hibernate.engine.spi.SelfDirtinessTracker)

Aggregations

Collection (java.util.Collection)1 CollectionTracker (org.hibernate.bytecode.enhance.spi.CollectionTracker)1 SelfDirtinessTracker (org.hibernate.engine.spi.SelfDirtinessTracker)1