微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.PreUpdate的实例源码

项目:os    文件CheckingEntityListener.java   
@PrePersist
@PreUpdate
public void encode(Object target) {
    AnnotationCheckingMetadata Metadata = AnnotationCheckingMetadata.getMetadata(target.getClass());
    if (Metadata.isCheckable()) {
        StringBuilder sb = new StringBuilder();
        for (Field field : Metadata.getCheckedFields()) {
            ReflectionUtils.makeAccessible(field);
            Object value = ReflectionUtils.getField(field,target);
            if (value instanceof Date) {
                throw new RuntimeException("不支持时间类型字段加密!");
            }
            sb.append(value).append(" - ");
        }
        sb.append(MD5_KEY);
        LOGGER.debug("加密数据:" + sb);
        String hex = MD5Utils.encode(sb.toString());
        Field checksumField = Metadata.getCheckableField();
        ReflectionUtils.makeAccessible(checksumField);
        ReflectionUtils.setField(checksumField,target,hex);
    }
}
项目:ha-db    文件CheckingEntityListener.java   
@PrePersist
@PreUpdate
public void encode(Object target) {
    AnnotationCheckingMetadata Metadata = AnnotationCheckingMetadata.getMetadata(target.getClass());
    if (Metadata.isCheckable()) {
        StringBuilder sb = new StringBuilder();
        for (Field field : Metadata.getCheckedFields()) {
            ReflectionUtils.makeAccessible(field);
            Object value = ReflectionUtils.getField(field,hex);
    }
}
项目:myWMS    文件ItemData.java   
/**
 * Checks,if constraints are kept during the prevIoUs operations.
 * 
 * @throws ConstraintViolatedException
 */
@PreUpdate
@PrePersist
public void sanityCheck() throws FacadeException {

    if( number != null ) {
        number = number.trim();
    }

       if( number != null && number.startsWith("* ") ) {
        number = number.substring(2);
       }

    if( number == null || number.length() == 0 ) {
        throw new BusinessException("number must be set");
    }

    if( getAdditionalContent() != null && getAdditionalContent().length() > 255)  {
        setAdditionalContent(getAdditionalContent().substring(0,255));
    }
}
项目:myWMS    文件ItemDatanumber.java   
/**
 * Checks,if some constraints are kept during the prevIoUs operations.
 * 
 * @throws FacadeException
 */
@PreUpdate
@PrePersist
public void sanityCheck() throws FacadeException {

    if( number != null ) {
        number = number.trim();
    }
    if( number != null && number.length()==0 ) {
        number = null;
    }

    if( itemData != null && !itemData.getClient().equals(getClient())) {
        setClient(itemData.getClient());
    }

}
项目:cibet    文件ResourceParameter.java   
@PrePersist
@PreUpdate
public void prePersist() {
   if (encodedValue == null && unencodedValue != null) {
      try {
         encodedValue = CibetUtil.encode(unencodedValue);
      } catch (IOException e) {
         throw new RuntimeException(e);
      }
   }

   if (parameterId == null) {
      parameterId = UUID.randomUUID().toString();
      log.debug("PREPERSIST: " + parameterId);
   }
}
项目:javaee8-jsf-sample    文件AuditEntityListener.java   
@PreUpdate
public void beforeUpdate(Object entity) {
    if (entity instanceof AbstractAuditableEntity) {
        AbstractAuditableEntity o = (AbstractAuditableEntity) entity;
        o.setLastModifiedDate(LocalDateTime.Now());

        if (o.getLastModifiedBy()== null) {
            o.setLastModifiedBy(currentUser());
        }
    }
}
项目:spring-data-examples    文件User.java   
/**
 * Makes sure only {@link User}s with encrypted {@link Password} can be persisted.
 */
@PrePersist
@PreUpdate
void assertEncrypted() {

    if (!password.isEncrypted()) {
        throw new IllegalStateException("Tried to persist/load a user with a non-encrypted password!");
    }
}
项目:xm-ms-entity    文件AvatarUrlListener.java   
@PrePersist
@PreUpdate
public void prePersist(XmEntity obj) {
    String avatarUrl = obj.getAvatarUrl();
    if (StringUtils.isNoneBlank(avatarUrl)) {
        if (avatarUrl.matches(PATTERN_FULL)) {
            obj.setAvatarUrl(FilenameUtils.getName(avatarUrl));
        } else {
            obj.setAvatarUrl(null);
        }
    }
}
项目: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,callbacksByType
    );
    createDefaultCallback(
            PreUpdate.class,PseudoJpaDotNames.DEFAULT_PRE_UPDATE,callbacksByType
    );
    createDefaultCallback(
            PostLoad.class,PseudoJpaDotNames.DEFAULT_POST_LOAD,callbacksByType
    );
    createDefaultCallback(
            PostPersist.class,PseudoJpaDotNames.DEFAULT_POST_PERSIST,callbacksByType
    );
    createDefaultCallback(
            PostRemove.class,PseudoJpaDotNames.DEFAULT_POST_REMOVE,callbacksByType
    );
    createDefaultCallback(
            PostUpdate.class,PseudoJpaDotNames.DEFAULT_POST_UPDATE,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>();
        createCallback( PrePersist.class,JPADotNames.PRE_PERSIST,callbackClassInfo,isListener );
        createCallback( PreRemove.class,JPADotNames.PRE_REMOVE,isListener );
        createCallback( PreUpdate.class,JPADotNames.PRE_UPDATE,isListener );
        createCallback( PostLoad.class,JPADotNames.POST_LOAD,isListener );
        createCallback( PostPersist.class,JPADotNames.POST_PERSIST,isListener );
        createCallback( PostRemove.class,JPADotNames.POST_REMOVE,isListener );
        createCallback( PostUpdate.class,JPADotNames.POST_UPDATE,isListener );
        if ( !callbacksByType.isEmpty() ) {
            callbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName,isListener ) );
        }
    }
项目:api.teiler.io    文件PersonEntity.java   
/**
 * Sets the update-time and creation-time to {@link Instant#Now()}.
 * <br>
 * <i>Note:</i> The creation-time will only be set if it has not been set prevIoUsly.
 */
@PreUpdate
@PrePersist
public void updateTimeStamps() {
    updateTime = new Timestamp(Instant.Now().toEpochMilli());
    if (createTime == null) {
        createTime = updateTime;
    }
}
项目:api.teiler.io    文件TransactionEntity.java   
/**
 * Sets the update-time and creation-time to {@link Instant#Now()}.
 * <br>
 * <i>Note:</i> The creation-time will only be set if it has not been set prevIoUsly.
 */
@PreUpdate
@PrePersist
public void updateTimeStamps() {
    updateTime = new Timestamp(Instant.Now().toEpochMilli());
    if (createTime == null) {
        createTime = updateTime;
    }
}
项目:api.teiler.io    文件ProfiteerEntity.java   
/**
 * Sets the update-time and creation-time to {@link Instant#Now()}.
 * <br>
 * <i>Note:</i> The creation-time will only be set if it has not been set prevIoUsly.
 */
@PreUpdate
@PrePersist
public void updateTimeStamps() {
    updateTime = new Timestamp(Instant.Now().toEpochMilli());
    if (createTime == null) {
        createTime = updateTime;
    }
}
项目:api.teiler.io    文件GroupEntity.java   
/**
 * Sets the update-time and creation-time to {@link Instant#Now()}.
 * <br>
 * <i>Note:</i> The creation-time will only be set if it has not been set prevIoUsly.
 */
@PreUpdate
@PrePersist
public void updateTimeStamps() {
    updateTime = new Timestamp(Instant.Now().toEpochMilli());
    if (createTime == null) {
        createTime = updateTime;
    }
}
项目:microservices-transactions-tcc    文件ChangeStateJpaListener.java   
@PreUpdate
void onPreUpdate(Object o) {
    String txId = (String)ThreadLocalContext.get(CompositeTransactionParticipantService.CURRENT_TRANSACTION_KEY);
    if (null == txId){
        LOG.info("onPreUpdate outside any transaction");
    } else {
        LOG.info("onPreUpdate inside transaction [{}]",txId);
        enlist(o,EntityCommand.Action.UPDATE,txId);
    }
}
项目:javaee8-jaxrs-sample    文件AuditEntityListener.java   
@PreUpdate
public void beforeUpdate(Object entity) {
    if (entity instanceof AbstractAuditableEntity) {
        AbstractAuditableEntity o = (AbstractAuditableEntity) entity;
        o.setLastModifiedDate(LocalDateTime.Now());

        if (o.getLastModifiedBy() == null) {
            o.setLastModifiedBy(currentUser());
        }
    }
}
项目:oma-riista-web    文件LifecycleEntity.java   
@PreUpdate
void preUpdate() {
    setModificationTimetoCurrentTime();

    final Long activeUserId = getActiveUserId();

    if (activeUserId >= 0 || getAuditFields().getModifiedByUserId() == null) {
        getAuditFields().setModifiedByUserId(activeUserId);
    }
}
项目:OSCAR-ConCert    文件FacilityMessage.java   
@PrePersist
@PreUpdate
protected void jpa_prePersistAndUpdate() {
    if(getProgramId() != null && getProgramId().intValue() == 0) {
        setProgramId(null);
    }
}
项目:coordinated-entry    文件BaseEntity.java   
@PreUpdate
protected void onUpdate(){
    dateUpdated = LocalDateTime.Now();
    if(SecurityContextUtil.getUserAccount()!=null) {
        userId = SecurityContextUtil.getUserAccount().getAccountId();
    }
}
项目:my-paper    文件Order.java   
/**
 * 更新前处理
 */
@PreUpdate
public void preUpdate() {
    if (getArea() != null) {
        setAreaName(getArea().getFullName());
    }
    if (getPaymentMethod() != null) {
        setPaymentMethodName(getPaymentMethod().getName());
    }
    if (getShippingMethod() != null) {
        setShippingMethodName(getShippingMethod().getName());
    }
}
项目:my-paper    文件Area.java   
/**
 * 更新前处理
 */
@PreUpdate
public void preUpdate() {
    Area parent = getParent();
    if (parent != null) {
        setFullName(parent.getFullName() + getName());
    } else {
        setFullName(getName());
    }
}
项目:my-paper    文件Receiver.java   
/**
 * 更新前处理
 */
@PreUpdate
public void preUpdate() {
    if (getArea() != null) {
        setAreaName(getArea().getFullName());
    }
}
项目:my-paper    文件Product.java   
/**
 * 更新前处理
 */
@PreUpdate
public void preUpdate() {
    if (getStock() == null) {
        setAllocatedStock(0);
    }
    if (getTotalscore() != null && getscoreCount() != null && getscoreCount() != 0) {
        setscore((float) getTotalscore() / getscoreCount());
    } else {
        setscore(0F);
    }
}
项目:coordinated-entry    文件HousingInventoryBaseEntity.java   
@PreUpdate
protected void onUpdate(){
    dateUpdated = LocalDateTime.Now();
    if(SecurityContextUtil.getUserAccount()!=null) {
        userId = SecurityContextUtil.getUserAccount().getAccountId();
    }
    if(SecurityContextUtil.getUserProjectGroup()!=null){
        projectGroupCode=SecurityContextUtil.getUserProjectGroup();
    }
}
项目:pcm-api    文件AbstractVersion.java   
@PreUpdate
public void preUpdate() {
    try {
        modificationTime = getCurrentDate();
    } catch (ParseException e) {
        modificationTime = new Date();
    }
}
项目:ee8-sandBox    文件Post.java   
@PreUpdate
public void beforeUpdate() {
    setUpdatedAt(LocalDateTime.Now());
    if (PUBLISHED == this.status) {
        setPublishedAt(LocalDateTime.Now());
    }
}
项目:sit-ad-archetype-javaee7-web    文件BaseEntityListener.java   
@PreUpdate
public void preUpdate(BaseEntity entity) {
    if (principal == null) {
        entity.setUpdatedBy("system");
    } else {
        entity.setUpdatedBy(principal.getName());
    }
}
项目:myWMS    文件LOSPickingPosition.java   
@PrePersist
@PreUpdate
// For hibernate only. By annotation it is called before saving
private void setRedundantValues() {
    if( pickingOrder == null ) {
        pickingOrderNumber = null;
    }
    else {
        pickingOrderNumber = pickingOrder.getNumber();
    }
}
项目:myWMS    文件LOsstorageLocation.java   
@PrePersist
@PreUpdate
public void checkValues() {
    if( scanCode == null ) {
        scanCode = name;
    }
}
项目:myWMS    文件LOSUnitLoad.java   
@PrePersist
@PreUpdate
public void sanityCheck() {
    if( weightMeasure != null && weightMeasure.compareto(BigDecimal.ZERO)>0 ) {
        weight = weightMeasure;
    }
    else if( weightCalculated != null && weightCalculated.compareto(BigDecimal.ZERO)>0 ) {
        weight = weightCalculated;
    }
}
项目:myWMS    文件LOSRack.java   
@PrePersist
@PreUpdate
public void checkValues() {
    if( aisle != null && aisle.trim().length()==0 ) {
        aisle = null;
    }
}
项目:celerio-angular-quickstart    文件User.java   
@PreUpdate
protected void preUpdate() {
    if (AuditContextHolder.audit()) {
        setLastModificationAuthor(AuditContextHolder.username());
        setLastModificationDate(Instant.Now());
    }
}
项目:cloud-pollutionmonitoringapp    文件BaSEObject.java   
/**
 * Life-cycle event callback,which automatically sets the last modification date.  
 */
@PreUpdate
protected void updateAudit@R_269_4045@ion() 
{
    lastModifiedAt = new Date();

    // Todo - obtain currently logged-on user
}
项目:site    文件PostEntity.java   
/**
 * Updates the {@link #updatedAt} timestamp
 */
@PrePersist
@PreUpdate
void updateUpdatedAt() {
    if (this.createdAt == null) {
        this.createdAt = Calendar.getInstance();
    }
    this.slug = generateSlug(slug,title);
    this.updatedAt = Calendar.getInstance();
}
项目:site    文件EventEntity.java   
@PrePersist
@PreUpdate
void prePersistAndUpdate() {
    if (this.createdAt == null) {
        this.createdAt = Calendar.getInstance();
    }
}
项目:Metasfresh-procurement-webui    文件AbstractEntity.java   
@PreUpdate
@PrePersist
public void updateCreatedUpdated()
{
    final Date Now = new Date();
    this.dateUpdated = Now;
    if (dateCreated == null)
    {
        dateCreated = Now;
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。