/** * PostLoad cannot occur during initializeEntity, as that call occurs *before* * the Set collections are added to the persistence context by Loader. * Without the split, LazyInitializationExceptions can occur in the Entity's * postLoad if it acts upon the collection. * * HHH-6043 * * @param entity The entity * @param session The Session * @param postLoadEvent The (re-used) post-load event */ public static void postLoad( final Object entity, final SessionImplementor session, final PostLoadEvent postLoadEvent) { if ( session.isEventSource() ) { final PersistenceContext persistenceContext = session.getPersistenceContext(); final EntityEntry entityEntry = persistenceContext.getEntry( entity ); postLoadEvent.setEntity( entity ).setId( entityEntry.getId() ).setPersister( entityEntry.getPersister() ); final EventListenerGroup<PostLoadEventListener> listenerGroup = session.getFactory() .getServiceRegistry() .getService( EventListenerRegistry.class ) .getEventListenerGroup( EventType.POST_LOAD ); for ( PostLoadEventListener listener : listenerGroup.listeners() ) { listener.onPostLoad( postLoadEvent ); } } }
private void postLoad( PostLoadEvent postLoadEvent, ResultSetProcessingContextImpl context, List<HydratedEntityRegistration> hydratedEntityRegistrations, List<AfterLoadAction> afterLoadActionList) { // Until this entire method is refactored w/ polymorphism, postLoad was // split off from initializeEntity. It *must* occur after // endCollectionLoad to ensure the collection is in the // persistence context. if ( hydratedEntityRegistrations == null ) { return; } for ( HydratedEntityRegistration registration : hydratedEntityRegistrations ) { TwoPhaseLoad.postLoad( registration.getInstance(), context.getSession(), postLoadEvent ); if ( afterLoadActionList != null ) { for ( AfterLoadAction afterLoadAction : afterLoadActionList ) { afterLoadAction.afterLoad( context.getSession(), registration.getInstance(), (Loadable) registration.getEntityReference().getEntityPersister() ); } } } }
/** * Retrieves the entity and triggers the onLoad lifecycle hook. * <p> * {@inheritDoc} */ @Override public void onPostLoad(PostLoadEvent event) { Object entity = event.getEntity(); if (entity instanceof ILifecycleCapable) { ((ILifecycleCapable) entity).onLoad(); } }
@Override public void onPostLoad(PostLoadEvent event) { final Object entity = event.getEntity(); final EntityEntry entry = event.getSession().getPersistenceContext().getEntry( entity ); if ( entry == null ) { throw new AssertionFailure( "possible non-threadsafe access to the session" ); } final LockMode lockMode = entry.getLockMode(); if ( LockMode.PESSIMISTIC_FORCE_INCREMENT.equals( lockMode ) ) { final EntityPersister persister = entry.getPersister(); final Object nextVersion = persister.forceVersionIncrement( entry.getId(), entry.getVersion(), event.getSession() ); entry.forceLocked( entity, nextVersion ); } else if ( LockMode.OPTIMISTIC_FORCE_INCREMENT.equals( lockMode ) ) { final EntityIncrementVersionProcess incrementVersion = new EntityIncrementVersionProcess( entity, entry ); event.getSession().getActionQueue().registerProcess( incrementVersion ); } else if ( LockMode.OPTIMISTIC.equals( lockMode ) ) { final EntityVerifyVersionProcess verifyVersion = new EntityVerifyVersionProcess( entity, entry ); event.getSession().getActionQueue().registerProcess( verifyVersion ); } if ( event.getPersister().implementsLifecycle() ) { //log.debug( "calling onLoad()" ); ( (Lifecycle) event.getEntity() ).onLoad( event.getSession(), event.getId() ); } }
/** * @see org.hibernate.event.spi.PostLoadEventListener#onPostLoad(org.hibernate * .event.spi.PostLoadEvent) */ @Override public void onPostLoad(PostLoadEvent event) { execute(postLoad, event.getEntity()); }
@Override public void onPostLoad(final PostLoadEvent event) { Member member = (Member) event.getEntity(); member.setAlias(service.alias()); }
@Override public void onPostLoad(final PostLoadEvent event) { System.out.println(System.identityHashCode(this)); System.out.println(event); }
@Override public void onPostLoad(PostLoadEvent event) { if (event.getEntity() instanceof PersistentObject) { ((PersistentObject) event.getEntity()).onLoad(); } }
@Override public void onPostLoad(PostLoadEvent ple) { autowired(); EntityMode entityMode = ple.getPersister().getEntityMode(); RuleContext ruleContext = new RuleContextImplNoPrincipal(ple.getEntity(), null); fireRules(ruleContext, ple.getPersister(), null, entityMode, RuleGroupPredefined.PostRead.class); }