Example usage for org.hibernate.proxy LazyInitializer setImplementation

List of usage examples for org.hibernate.proxy LazyInitializer setImplementation

Introduction

In this page you can find the example usage for org.hibernate.proxy LazyInitializer setImplementation.

Prototype

void setImplementation(Object target);

Source Link

Document

Initialize the proxy manually by injecting its target.

Usage

From source file:org.babyfish.hibernate.proxy.FrozenLazyInitializerImpl.java

License:Open Source License

@Override
public void setImplementation(Object target) {
    LazyInitializer rawLazyInitializer = this.lazyInitializer;
    Object oldTarget = rawLazyInitializer.isUninitialized() ? null : rawLazyInitializer.getImplementation();
    if (target != oldTarget) {
        ScalarListener listener = this.new TargetScalarListener();
        if (oldTarget != null) {
            this.omFactory.get(oldTarget).removeScalarListener(listener);
        }//from  ww  w . j a va2 s .  co m
        rawLazyInitializer.setImplementation(target);
        this.oldTarget = target;
        if (target != null) {
            ObjectModel targetOM = this.omFactory.get(target);
            targetOM.removeScalarListener(listener); //remove the duplicated listener.
            targetOM.addScalarListener(listener);
        }
    }
}