Java 类javax.persistence.PostUpdate 实例源码

项目:spring-data-rest-webhook    文件:WebhookEntityListener.java   
@PostUpdate
@Async
public void postUpdate(Object object) {
    LOG.info("Listening to post update for object:" + object);
    // Entitys have to be annotated with @EventListeners and reference this class in that annotation, because of this
    // the usages of this class are not executed withing the handle of the Spring context. So now we have to use this funky
    // ass way of wiring in fields AS this method is being called. #sadface
    AutowireHelper.autowire(this);
    // Trying to just add @Transactional(Transactional.TxType.REQUIRES_NEW) to this method didn't work at all, it was just being ignored.
    // This wrapper is what ended up working.
    TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
        @Override
        public void afterCompletion(int status) {
            super.afterCompletion(status);
            List<Webhook> hooks = webhookManager.retrieveWebhooksByEntityNameAndEventType(object.getClass().getSimpleName(), "post-update");
            hooks.stream().forEach(wh -> webhookProcessor.notifyWebhook(wh, object));
        }
    });

}
项目:lams    文件:EntityClass.java   
private void processDefaultJpaCallbacks(String instanceCallbackClassName, List<JpaCallbackClass> jpaCallbackClassList) {
    ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName );

    // Process superclass first if available and not excluded
    if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) {
        DotName superName = callbackClassInfo.superName();
        if ( superName != null ) {
            processDefaultJpaCallbacks( instanceCallbackClassName, jpaCallbackClassList );
        }
    }

    String callbackClassName = callbackClassInfo.name().toString();
    Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>();
    createDefaultCallback(
            PrePersist.class, PseudoJpaDotNames.DEFAULT_PRE_PERSIST, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PreRemove.class, PseudoJpaDotNames.DEFAULT_PRE_REMOVE, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PreUpdate.class, PseudoJpaDotNames.DEFAULT_PRE_UPDATE, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PostLoad.class, PseudoJpaDotNames.DEFAULT_POST_LOAD, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PostPersist.class, PseudoJpaDotNames.DEFAULT_POST_PERSIST, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PostRemove.class, PseudoJpaDotNames.DEFAULT_POST_REMOVE, callbackClassName, callbacksByType
    );
    createDefaultCallback(
            PostUpdate.class, PseudoJpaDotNames.DEFAULT_POST_UPDATE, callbackClassName, callbacksByType
    );
    if ( !callbacksByType.isEmpty() ) {
        jpaCallbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, true ) );
    }
}
项目:lams    文件:EntityClass.java   
private void processJpaCallbacks(String instanceCallbackClassName, boolean isListener, List<JpaCallbackClass> callbackClassList) {

        ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName );

        // Process superclass first if available and not excluded
        if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) {
            DotName superName = callbackClassInfo.superName();
            if ( superName != null ) {
                processJpaCallbacks(
                        instanceCallbackClassName,
                        isListener,
                        callbackClassList
                );
            }
        }

        Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>();
        createCallback( PrePersist.class, JPADotNames.PRE_PERSIST, callbacksByType, callbackClassInfo, isListener );
        createCallback( PreRemove.class, JPADotNames.PRE_REMOVE, callbacksByType, callbackClassInfo, isListener );
        createCallback( PreUpdate.class, JPADotNames.PRE_UPDATE, callbacksByType, callbackClassInfo, isListener );
        createCallback( PostLoad.class, JPADotNames.POST_LOAD, callbacksByType, callbackClassInfo, isListener );
        createCallback( PostPersist.class, JPADotNames.POST_PERSIST, callbacksByType, callbackClassInfo, isListener );
        createCallback( PostRemove.class, JPADotNames.POST_REMOVE, callbacksByType, callbackClassInfo, isListener );
        createCallback( PostUpdate.class, JPADotNames.POST_UPDATE, callbacksByType, callbackClassInfo, isListener );
        if ( !callbacksByType.isEmpty() ) {
            callbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, isListener ) );
        }
    }
项目:OperatieBRP    文件:GegevenInOnderzoekListener.java   
/**
 * Als dit een entiteit anders dan gegeven in onderzoek betreft dan moet de link naar gegegeven
 * in onderzoek worden hersteld.
 *
 * @param entity de opgeslagen entiteit
 */
@PostPersist
@PostUpdate
public void postSave(final Object entity) {
    if (entity instanceof Entiteit && !(entity instanceof GegevenInOnderzoek)) {
        final Entiteit entiteit = (Entiteit) entity;
        for (final GegevenInOnderzoek gegevenInOnderzoek : entiteit.getGegevenInOnderzoekPerElementMap().values()) {
            if (gegevenInOnderzoek.getEntiteitOfVoorkomen() != entity) {
                gegevenInOnderzoek.setEntiteitOfVoorkomen(entiteit);
            }
        }
    }
}
项目:IdentityRegistry    文件:Organization.java   
@PostPersist
@PostUpdate
public void setChildIds() {
    super.setChildIds();
    if (this.identityProviderAttributes != null) {
        for (IdentityProviderAttribute attr : this.identityProviderAttributes) {
            attr.setOrganization(this);
        }
    }
}
项目:IdentityRegistry    文件:Vessel.java   
@PostPersist
@PostUpdate
public void setChildIds() {
    super.setChildIds();
    if (this.attributes != null) {
        for (VesselAttribute attr : this.attributes) {
            attr.setVessel(this);
        }
    }
}
项目:IdentityRegistry    文件:CertificateModel.java   
@PostPersist
@PostUpdate
public void setChildIds() {
    if (getCertificates() != null) {
        getCertificates().forEach(this::assignToCert);
    }
}
项目:jpasecurity    文件:FieldAccessAnnotationTestBean.java   
@PostUpdate
public void postUpdateLifecycleMethod() {
    postUpdateCount++;
    if (postUpdateCount != preUpdateCount) {
        throw new IllegalStateException("postUpdateCount(" + postUpdateCount + ") != preUpdateCount(" + preUpdateCount + ")");
    }
}
项目:metaworks_framework    文件:CustomerPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext after the transaction has completed.
 * 
 * @param entity the newly-persisted Customer
 * @see CustomerPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new CustomerPersistedEvent((Customer) entity));
            }
        });
    }
}
项目:metaworks_framework    文件:OrderPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext to allow an event listener to respond appropriately (like resetting the current cart
 * in CartState)
 * 
 * @param entity the newly-persisted Order
 * @see OrderPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new OrderPersistedEvent((Order) entity));
            }
        });
    }
}
项目:SparkCommerce    文件:OrderPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext to allow an event listener to respond appropriately (like resetting the current cart
 * in CartState)
 * 
 * @param entity the newly-persisted Order
 * @see OrderPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new OrderPersistedEvent((Order) entity));
            }
        });
    }
}
项目:SparkCore    文件:CustomerPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext after the transaction has completed.
 * 
 * @param entity the newly-persisted Customer
 * @see CustomerPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new CustomerPersistedEvent((Customer) entity));
            }
        });
    }
}
项目:SparkCore    文件:OrderPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext to allow an event listener to respond appropriately (like resetting the current cart
 * in CartState)
 * 
 * @param entity the newly-persisted Order
 * @see OrderPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new OrderPersistedEvent((Order) entity));
            }
        });
    }
}
项目:che    文件:ProjectConfigImpl.java   
@PostLoad
@PostUpdate
@PostPersist
private void postLoadAttributes() {
  if (dbAttributes != null) {
    attributes =
        dbAttributes.values().stream().collect(toMap(attr -> attr.name, attr -> attr.values));
  }
}
项目:sakai    文件:Criterion.java   
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Rubric rubric = getRubric();
    if (rubric != null && rubric.getMetadata().isShared()) {
        getMetadata().setShared(true);
    }
}
项目:sakai    文件:Rubric.java   
@PostLoad
@PostUpdate
public void determineLockStatus() {
    if (getToolItemAssociations() != null && getToolItemAssociations().size() > 0) {
        getMetadata().setLocked(true);
    }
}
项目:sakai    文件:Rating.java   
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Criterion criterion = getCriterion();
    if (criterion != null) {
        Rubric rubric = criterion.getRubric();
        if (rubric != null && rubric.getMetadata().isShared()) {
            getMetadata().setShared(true);
        }
    }
}
项目:blcdemo    文件:CustomerPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext after the transaction has completed.
 * 
 * @param entity the newly-persisted Customer
 * @see CustomerPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new CustomerPersistedEvent((Customer) entity));
            }
        });
    }
}
项目:blcdemo    文件:OrderPersistedEntityListener.java   
/**
 * Invoked on both the PostPersist and PostUpdate. The default implementation is to simply publish a Spring event
 * to the ApplicationContext to allow an event listener to respond appropriately (like resetting the current cart
 * in CartState)
 * 
 * @param entity the newly-persisted Order
 * @see OrderPersistedEvent
 */
@PostPersist
@PostUpdate
public void customerUpdated(final Object entity) {
    if (TransactionSynchronizationManager.isSynchronizationActive()) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                ApplicationContextHolder.getApplicationContext().publishEvent(new OrderPersistedEvent((Order) entity));
            }
        });
    }
}
项目:mytourbook    文件:TourData.java   
/**
 * Called after the object was loaded from the persistence store
 */
@PostLoad
@PostUpdate
public void onPostLoad() {

    /*
     * disable post load when database is updated from 19 to 20 because data are converted
     */
    if (TourDatabase.IS_POST_UPDATE_019_to_020) {
        return;
    }

    onPostLoadGetDataSeries();
}
项目:spring-entity-listener    文件:PasswordListener.java   
/**
 * Decrypt password after loading.
 */
@PostLoad
@PostUpdate
public void decryptPassword(TwitterUser user) {
    user.setPassword(null);

    if (user.getEncryptedPassword() != null) {
        user.setPassword(encryptor.decryptString(user.getEncryptedPassword(), user.getSalt()));
    }

    // obviously we would never do this in practice
    System.out.printf("decrypted password '%s'\n", user.getPassword());
}
项目:sakai    文件:Criterion.java   
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Rubric rubric = getRubric();
    if (rubric != null && rubric.getMetadata().isShared()) {
        getMetadata().setShared(true);
    }
}
项目:sakai    文件:Rubric.java   
@PostLoad
@PostUpdate
public void determineLockStatus() {
    if (getToolItemAssociations() != null && getToolItemAssociations().size() > 0) {
        getMetadata().setLocked(true);
    }
}
项目:sakai    文件:Rating.java   
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Criterion criterion = getCriterion();
    if (criterion != null) {
        Rubric rubric = criterion.getRubric();
        if (rubric != null && rubric.getMetadata().isShared()) {
            getMetadata().setShared(true);
        }
    }
}
项目:soda4lca    文件:Organization.java   
/**
 * Empty address means only <code>null</code> values in DB &rArr; address
 * is null after load from DB. If address is <code>null</code>, it will
 * be initialized with an empty address object.
 */
@PostLoad
@PostUpdate
protected void postLoad() {
    if ( this.address == null ) {
        this.address = new Address();
    }
}
项目:soda4lca    文件:User.java   
/**
 * Empty address means only <code>null</code> values in DB &rArr; address
 * is null after load from DB. If address is <code>null</code>, it will
 * be initialized with an empty address object.
 */
@PostLoad
@PostUpdate
protected void postLoad() {
    if ( this.address == null ) {
        this.address = new Address();
    }
}
项目:apiman    文件:PolicyBean.java   
@PostPersist @PostUpdate @PostLoad
protected void decryptData() {
    // Decrypt the endpoint properties.
    EntityType entityType = EntityType.Api;
    if (type == PolicyType.Client) {
        entityType = EntityType.ClientApp;
    } else if (type == PolicyType.Plan) {
        entityType = EntityType.Plan;
    }
    DataEncryptionContext ctx = new DataEncryptionContext(organizationId, entityId, entityVersion, entityType);
    configuration = CurrentDataEncrypter.instance.decrypt(configuration, ctx);
}
项目:java-microservice    文件:ToDoEntityListener.java   
@PostUpdate
public void onUpdate(ToDo todo) {
    AutowireHelper.autowire(this, this.publisher);
    this.publisher.publish(new TodoUpdatedEvent(todo));
}
项目:esup-ecandidat    文件:EntityPushEntityListener.java   
@PostUpdate
public void postUpdate(Object entity) {
    notifyEntityPushers(EntityAction.UPDATED, entity);
}
项目:DanielDias-MongoDB    文件:JPADebugListener.java   
@PostUpdate
private void postUpdate(Object object) {
    logger.debug("### DebugListener.postUpdate({})", object);
}
项目:OSCAR-ConCert    文件:DSGuidelineDrools.java   
@PostUpdate
public void afterSave() {
    RuleBaseFactory.removeRuleBase(getRuleBaseFactoryKey());
}
项目:OSCAR-ConCert    文件:AppointmentStatus.java   
@PostPersist
@PostUpdate
public void on_jpa_update() {
    AppointmentStatusMgrImpl.setCacheIsDirty(true);
}
项目:SMSC    文件:EncryptionListener.java   
/**
 * Method to decrypt password after user loading.
 *
 * @param obj the {@link User} whose password should be decrypted
 */
@PostLoad
@PostUpdate
public void decrypt(Object obj) throws IllegalAccessException {
    EncrypterUtil.decrypt(obj);
}
项目:warpdb    文件:User.java   
@PostUpdate
void postUpdate() {
    callbacks.add(PostUpdate.class);
}
项目:OpenCyclos    文件:WriteDetectEventListener.java   
@PostRemove
@PostPersist
@PostUpdate
public void onPostModyfingOperation(final Object o) {
    markWrite();
}
项目:apolo    文件:AuditLogListener.java   
@PostUpdate
void postUpdate(AuditableBaseEntity e) {
    createLog(DatabaseTransactionType.UPDATE, e);
}
项目:tapestry-jpa-transactions    文件:CommitCounter.java   
@PostPersist
@PostUpdate
private void updateVersion(Object entity)
{
    versionedThing.get().updateVersion(entity);
}
项目:spring-entity-listener    文件:SpringListener.java   
@PostUpdate
public void postUpdate(TwitterUser entity) {
    System.out.println("Spring PostUpdate, key: " + key);
}