Java 类javax.persistence.PostPersist 实例源码

项目:dionysus    文件:NotificationListener.java   
@PostPersist
public void sendNotification(Notifiable<User> entity) {
  User from = entity.receiveFrom();
  Collection<User> tos = entity.sendTo();
  String summary = entity.getSummary();

  for (User to : tos) {
    Inbox inbox = to.getInbox();
    Notification notification = new Notification(inbox, from, summary);
    //ugly tentatively using this inject
    if (this.notificationRepository == null) {
      AutowireInjector.inject(this, this.notificationRepository);
    }
    notificationRepository.save(notification);
  }
}
项目:JMaNGOS    文件:FieldsObject.java   
@PostPersist
private final void packGuid() {

    if (this.guid == null) {
        return;
    }
    long tguid = this.guid;
    final byte[] packGUID = new byte[8 + 1];
    packGUID[0] = 0;
    int size = 1;
    for (byte i = 0; i < 8; ++i) {
        if ((tguid & 0xFF) > 0) {
            packGUID[0] |= (1 << i);
            packGUID[size] = (byte) (tguid & 0xFF);
            ++size;
        }

        tguid >>= 8;
    }
    this.packGuid = new byte[size];
    for (int i = 0; i < size; i++) {
        this.packGuid[i] = packGUID[i];
    }
}
项目:java-microservice    文件:ToDoEntityListener.java   
@PostPersist
public void onPersist(ToDo todo) {
    //ToDoPersistenceMonitor is not a spring managed been, so we need to inject 
    //  publisher using this simple helper
    AutowireHelper.autowire(this, this.publisher);
    this.publisher.publish(new TodoCreatedEvent(todo));
}
项目: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);
            }
        }
    }
}
项目:example-ddd-with-spring-data-jpa    文件:SpringEntityListener.java   
@PostLoad
@PostPersist
public void inject(Object object) {
    AutowireCapableBeanFactory beanFactory = get().getBeanFactory();
    if(beanFactory == null) {
        LOG.warn("Bean Factory not set! Depdendencies will not be injected into: '{}'", object);
        return;
    }
    LOG.debug("Injecting dependencies into entity: '{}'.", object);
    beanFactory.autowireBean(object);
}
项目: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   
@PostPersist
public void postPersistLifecycleMethod() {
    postPersistCount++;
    if (postPersistCount != prePersistCount) {
        throw new IllegalStateException("postPersistCount(" + postPersistCount + ") != prePersistCount(" + prePersistCount + ")");
    }
}
项目:springJpaKata    文件:SampleListener.java   
@PreUpdate
@PostPersist
@PrePersist
public void setLastUpdate( Person p ) {
    if("addAction".equals(p.getFirstname())){
    p.setActive(true);}

    log.info("person after set active on true , before save action : {}",p);
}
项目: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));
  }
}
项目:actionbazaar    文件:CategoryNotifier.java   
@PostPersist
public void newCategoryNotification(Category category) {

   // Notification.sendEmailAlert(category.getCategoryId(), category
    //        .getCategoryName(), category.getUser().getFirstName(), category
  //          .getUser().getLastName());
}
项目: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));
            }
        });
    }
}
项目:hsw    文件:NewEntityListener.java   
@PostPersist
protected void newEntity(Object entity) {
    try {
        News news = new News(entity);
        EntityManager em = getEntityManager();
        if (em != null) {
            em.persist(news);
        }
    } catch (Exception e) {
        // Keine Nachrichten sind gute Nachrichten ;-)
    }
}
项目:oscar-old    文件:BillingClaimHeader1.java   
@PostPersist
public void postPersist() {
    Iterator<BillingItem> i = this.billingItems.iterator();
    BillingItem item;
    while(i.hasNext()) {
        item = i.next();
        item.setCh1_id(id);
    }
}
项目: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);
}
项目:yum    文件:DailyMenu.java   
@PostPersist
private void getLastEditAfterPost(){
    this.setLastEdit(this.getLastEdit());
    System.out.println("@PostPersist:"+this.lastEdit); 

}
项目:esup-ecandidat    文件:EntityPushEntityListener.java   
@PostPersist
public void postPersist(Object entity) {
    notifyEntityPushers(EntityAction.PERSISTED, entity);
}
项目:esup-sgc    文件:Card.java   
@PostPersist
public void updateNbCards() {
    int nbCards = 1 + this.getUser().getCards().size();
    this.getUser().setNbCards((long) nbCards);
}
项目:spring-data-rest-webhook    文件:WebhookEntityListener.java   
@PostPersist
public void postPersist(Object object) {
    LOG.info("Listening to post persist for object:" + object);
}
项目:DanielDias-MongoDB    文件:JPADebugListener.java   
@PostPersist
private void postPersist(Object object) {
    logger.debug("### DebugListener.postPersist({})", object);
}
项目:OSCAR-ConCert    文件:AppointmentStatus.java   
@PostPersist
@PostUpdate
public void on_jpa_update() {
    AppointmentStatusMgrImpl.setCacheIsDirty(true);
}
项目:OSCAR-ConCert    文件:BillingONCHeader1.java   
@PostPersist
public void postPersist() {            
    for (BillingONItem b : this.billingItems) {
        b.setCh1Id(this.id);
    }                        
}
项目:warpdb    文件:User.java   
@PostPersist
void postPersist() {
    callbacks.add(PostPersist.class);
}
项目:OpenCyclos    文件:WriteDetectEventListener.java   
@PostRemove
@PostPersist
@PostUpdate
public void onPostModyfingOperation(final Object o) {
    markWrite();
}
项目:apolo    文件:AuditLogListener.java   
@PostPersist
void postPersist(AuditableBaseEntity e) {
    createLog(DatabaseTransactionType.CREATE, e);
}
项目:tapestry-jpa-transactions    文件:CommitCounter.java   
@PostPersist
@PostUpdate
private void updateVersion(Object entity)
{
    versionedThing.get().updateVersion(entity);
}
项目:olingo-odata2    文件:SalesOrderHeader.java   
@PostPersist
public void defaultValues() {
  if (creationDate == null) {
    setCreationDate(creationDate);
  }
}
项目:spring-entity-listener    文件:SpringListener.java   
@PostPersist
public void postPersist(TwitterUser entity) {
    System.out.println("Spring PostPersist, key: " + key);
}
项目:spring-entity-listener    文件:HibernateEntityListenersAdapter.java   
public void findMethodsForListener(Object listener) {
    Class<?> c = listener.getClass();
    for (Method m : c.getMethods()) {
        if (Void.TYPE.equals(m.getReturnType())) {
            Class<?>[] types = m.getParameterTypes();
            if (types.length == 1) {
                // check for all annotations now...
                if (m.getAnnotation(PrePersist.class) != null) {
                    if (!preInsert.containsKey(types[0])) {
                        preInsert.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    preInsert.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PostPersist.class) != null) {
                    if (!postInsert.containsKey(types[0])) {
                        postInsert.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    postInsert.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PreUpdate.class) != null) {
                    if (!preUpdate.containsKey(types[0])) {
                        preUpdate.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    preUpdate.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PostUpdate.class) != null) {
                    if (!postUpdate.containsKey(types[0])) {
                        postUpdate.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    postUpdate.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PreRemove.class) != null) {
                    if (!preRemove.containsKey(types[0])) {
                        preRemove.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    preRemove.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PostRemove.class) != null) {
                    if (!postRemove.containsKey(types[0])) {
                        postRemove.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    postRemove.get(types[0]).put(m, listener);
                }

                if (m.getAnnotation(PostLoad.class) != null) {
                    if (!postLoad.containsKey(types[0])) {
                        postLoad.put(types[0], new LinkedHashMap<Method, Object>());
                    }
                    postLoad.get(types[0]).put(m, listener);
                }
            }
        }
    }
}
项目:spring-entity-listener    文件:JPAListener.java   
@PostPersist
public void postPersist(TwitterUser entity) {
    System.out.println("JPA PostPersist");
}