Example usage for org.hibernate.event.spi PostLoadEvent getEntity

List of usage examples for org.hibernate.event.spi PostLoadEvent getEntity

Introduction

In this page you can find the example usage for org.hibernate.event.spi PostLoadEvent getEntity.

Prototype

public Object getEntity() 

Source Link

Usage

From source file:com.invariantproperties.sandbox.springentitylistener.listener.HibernateEntityListenersAdapter.java

License:Apache License

/**
 * @see org.hibernate.event.spi.PostLoadEventListener#onPostLoad(org.hibernate
 *      .event.spi.PostLoadEvent)/*  w w  w  .j a  v a2  s. c om*/
 */
@Override
public void onPostLoad(PostLoadEvent event) {
    execute(postLoad, event.getEntity());
}

From source file:debop4k.data.orm.hibernate.listener.PersistentObjectListener.java

License:Apache License

@Override
public void onPostLoad(PostLoadEvent event) {
    if (isPersistentObject(event.getEntity())) {
        ((PersistentObject) event.getEntity()).onLoad();
    }/*from  w w  w . j  av  a 2 s. c o  m*/
}

From source file:es.logongas.ix3.dao.impl.rules.EventListenerImplRuleEngine.java

License:Apache License

@Override
public void onPostLoad(PostLoadEvent ple) {
    autowired();//from   w ww. j  av  a 2  s  .com
    EntityMode entityMode = ple.getPersister().getEntityMode();

    RuleContext ruleContext = new RuleContextImplNoPrincipal(ple.getEntity(), null);

    fireRules(ruleContext, ple.getPersister(), null, entityMode, RuleGroupPredefined.PostRead.class);

}

From source file:org.grails.orm.hibernate.event.listener.HibernateEventListener.java

License:Apache License

public void onPostLoad(PostLoadEvent event) {
    ClosureEventListener eventListener = findEventListener(event.getEntity(),
            event.getPersister().getFactory());
    if (eventListener != null) {
        eventListener.onPostLoad(event);
    }//from   w w w .  j ava2 s . c om
}

From source file:org.grails.orm.hibernate.EventTriggeringInterceptor.java

License:Apache License

public void onPostLoad(PostLoadEvent event) {
    ClosureEventListener eventListener = findEventListener(event.getEntity());
    if (eventListener != null) {
        eventListener.onPostLoad(event);
    }// w  w  w .  j av a 2s. c o  m
}

From source file:org.grails.orm.hibernate.support.ClosureEventListener.java

License:Apache License

public void onPostLoad(final PostLoadEvent event) {
    if (postLoadEventListener == null) {
        return;/*from ww w . j  a va  2  s . c  o  m*/
    }

    doWithManualSession(event, new Closure(this) {
        @Override
        public Object call() {
            postLoadEventListener.call(event.getEntity());
            return null;
        }
    });
}

From source file:org.grails.orm.hibernate.support.ClosureEventTriggeringInterceptor.java

License:Apache License

public void onPostLoad(PostLoadEvent hibernateEvent) {
    publishEvent(hibernateEvent, new org.grails.datastore.mapping.engine.event.PostLoadEvent(
            findDatastore(hibernateEvent), hibernateEvent.getEntity()));
}

From source file:org.jspresso.framework.application.backend.persistence.hibernate.LifecyclePostLoadEventListener.java

License:Open Source License

/**
 * Retrieves the entity and triggers the onLoad lifecycle hook.
 * <p>/*w  w w.ja v  a 2s . com*/
 * {@inheritDoc}
 */
@Override
public void onPostLoad(PostLoadEvent event) {
    Object entity = event.getEntity();
    if (entity instanceof ILifecycleCapable) {
        ((ILifecycleCapable) entity).onLoad();
    }
}

From source file:org.openmrs.ObsPostLoadEventListener.java

License:Mozilla Public License

@Override
public void onPostLoad(PostLoadEvent event) {
    if (Obs.class.isAssignableFrom(event.getEntity().getClass())) {
        Field field = null;/*from www  . j a v a  2s  . c  o m*/
        try {
            field = Obs.class.getDeclaredField("dirty");
            field.setAccessible(true);
            field.set(event.getEntity(), false);
        } catch (ReflectiveOperationException e) {
            log.error("Failed to unset an Obs as dirty after being loaded from the database", e);
        } finally {
            if (field != null) {
                field.setAccessible(false);
            }
        }
    }
}