當前位置: 首頁>>代碼示例>>Java>>正文


Java PostPersist類代碼示例

本文整理匯總了Java中javax.persistence.PostPersist的典型用法代碼示例。如果您正苦於以下問題:Java PostPersist類的具體用法?Java PostPersist怎麽用?Java PostPersist使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PostPersist類屬於javax.persistence包,在下文中一共展示了PostPersist類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendNotification

import javax.persistence.PostPersist; //導入依賴的package包/類
@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);
  }
}
 
開發者ID:perrywang,項目名稱:dionysus,代碼行數:17,代碼來源:NotificationListener.java

示例2: packGuid

import javax.persistence.PostPersist; //導入依賴的package包/類
@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];
    }
}
 
開發者ID:JMaNGOS,項目名稱:JMaNGOS,代碼行數:25,代碼來源:FieldsObject.java

示例3: onPersist

import javax.persistence.PostPersist; //導入依賴的package包/類
@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));
}
 
開發者ID:apssouza22,項目名稱:java-microservice,代碼行數:8,代碼來源:ToDoEntityListener.java

示例4: processDefaultJpaCallbacks

import javax.persistence.PostPersist; //導入依賴的package包/類
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 ) );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:EntityClass.java

示例5: processJpaCallbacks

import javax.persistence.PostPersist; //導入依賴的package包/類
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 ) );
		}
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:EntityClass.java

示例6: postSave

import javax.persistence.PostPersist; //導入依賴的package包/類
/**
 * 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);
            }
        }
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:19,代碼來源:GegevenInOnderzoekListener.java

示例7: inject

import javax.persistence.PostPersist; //導入依賴的package包/類
@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);
}
 
開發者ID:CK35,項目名稱:example-ddd-with-spring-data-jpa,代碼行數:12,代碼來源:SpringEntityListener.java

示例8: setChildIds

import javax.persistence.PostPersist; //導入依賴的package包/類
@PostPersist
@PostUpdate
public void setChildIds() {
    super.setChildIds();
    if (this.identityProviderAttributes != null) {
        for (IdentityProviderAttribute attr : this.identityProviderAttributes) {
            attr.setOrganization(this);
        }
    }
}
 
開發者ID:MaritimeConnectivityPlatform,項目名稱:IdentityRegistry,代碼行數:11,代碼來源:Organization.java

示例9: setChildIds

import javax.persistence.PostPersist; //導入依賴的package包/類
@PostPersist
@PostUpdate
public void setChildIds() {
    super.setChildIds();
    if (this.attributes != null) {
        for (VesselAttribute attr : this.attributes) {
            attr.setVessel(this);
        }
    }
}
 
開發者ID:MaritimeConnectivityPlatform,項目名稱:IdentityRegistry,代碼行數:11,代碼來源:Vessel.java

示例10: setChildIds

import javax.persistence.PostPersist; //導入依賴的package包/類
@PostPersist
@PostUpdate
public void setChildIds() {
    if (getCertificates() != null) {
        getCertificates().forEach(this::assignToCert);
    }
}
 
開發者ID:MaritimeConnectivityPlatform,項目名稱:IdentityRegistry,代碼行數:8,代碼來源:CertificateModel.java

示例11: postPersistLifecycleMethod

import javax.persistence.PostPersist; //導入依賴的package包/類
@PostPersist
public void postPersistLifecycleMethod() {
    postPersistCount++;
    if (postPersistCount != prePersistCount) {
        throw new IllegalStateException("postPersistCount(" + postPersistCount + ") != prePersistCount(" + prePersistCount + ")");
    }
}
 
開發者ID:ArneLimburg,項目名稱:jpasecurity,代碼行數:8,代碼來源:FieldAccessAnnotationTestBean.java

示例12: setLastUpdate

import javax.persistence.PostPersist; //導入依賴的package包/類
@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);
}
 
開發者ID:przodownikR1,項目名稱:springJpaKata,代碼行數:10,代碼來源:SampleListener.java

示例13: testInsert

import javax.persistence.PostPersist; //導入依賴的package包/類
@Test
public void testInsert() throws Exception {
	User user = new User();
	user.name = "Michael";
	user.email = "[email protected]";
	warpdb.save(user);
	assertTrue(user.callbacks.contains(PrePersist.class));
	assertTrue(user.callbacks.contains(PostPersist.class));
	assertEquals("0001", user.id);
	assertEquals(user.createdAt, user.updatedAt);
	assertEquals(System.currentTimeMillis(), user.createdAt, 500);
}
 
開發者ID:michaelliao,項目名稱:warpdb,代碼行數:13,代碼來源:WarpDbCRUDAndCallbackTest.java

示例14: customerUpdated

import javax.persistence.PostPersist; //導入依賴的package包/類
/**
 * 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));
            }
        });
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:20,代碼來源:CustomerPersistedEntityListener.java

示例15: customerUpdated

import javax.persistence.PostPersist; //導入依賴的package包/類
/**
 * 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));
            }
        });
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:21,代碼來源:OrderPersistedEntityListener.java


注:本文中的javax.persistence.PostPersist類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。