当前位置: 首页>>代码示例>>Java>>正文


Java PostUpdate类代码示例

本文整理汇总了Java中javax.persistence.PostUpdate的典型用法代码示例。如果您正苦于以下问题:Java PostUpdate类的具体用法?Java PostUpdate怎么用?Java PostUpdate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PostUpdate类属于javax.persistence包,在下文中一共展示了PostUpdate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postUpdate

import javax.persistence.PostUpdate; //导入依赖的package包/类
@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));
        }
    });

}
 
开发者ID:jfillo,项目名称:spring-data-rest-webhook,代码行数:21,代码来源:WebhookEntityListener.java

示例2: testUpdate

import javax.persistence.PostUpdate; //导入依赖的package包/类
@Test
public void testUpdate() throws Exception {
	User user = new User();
	user.name = "Michael";
	user.email = "[email protected]";
	warpdb.save(user);
	Thread.sleep(100);
	user.name = "Changed";
	user.email = "[email protected]";
	warpdb.update(user);
	assertTrue(user.callbacks.contains(PreUpdate.class));
	assertTrue(user.callbacks.contains(PostUpdate.class));
	assertNotEquals(user.createdAt, user.updatedAt);
	assertEquals(System.currentTimeMillis(), user.updatedAt, 500);
	// fetch:
	User bak = warpdb.fetch(User.class, user.id);
	assertNotNull(bak);
	assertEquals(user.id, bak.id);
	assertEquals("Changed", bak.name);
	// email is set updatable=false:
	assertEquals("[email protected]", bak.email);
	assertEquals(user.createdAt, bak.createdAt);
	assertEquals(user.updatedAt, bak.updatedAt);
	assertEquals(user.version, bak.version);
}
 
开发者ID:michaelliao,项目名称:warpdb,代码行数:26,代码来源:WarpDbCRUDAndCallbackTest.java

示例3: testUpdateProperties

import javax.persistence.PostUpdate; //导入依赖的package包/类
@Test
public void testUpdateProperties() throws Exception {
	User user = new User();
	user.name = "Michael";
	user.email = "[email protected]";
	warpdb.save(user);
	Thread.sleep(100);
	user.name = "Changed";
	user.version = 99;
	warpdb.updateProperties(user, "name", "version", "updatedAt");
	assertTrue(user.callbacks.contains(PreUpdate.class));
	assertTrue(user.callbacks.contains(PostUpdate.class));
	assertNotEquals(user.createdAt, user.updatedAt);
	assertEquals(System.currentTimeMillis(), user.updatedAt, 500);
	// fetch:
	User bak = warpdb.fetch(User.class, user.id);
	assertNotNull(bak);
	assertEquals(user.id, bak.id);
	assertEquals("Changed", bak.name);
	assertEquals("Changed", bak.name);
	assertEquals(99, bak.version);
}
 
开发者ID:michaelliao,项目名称:warpdb,代码行数:23,代码来源:WarpDbCRUDAndCallbackTest.java

示例4: processDefaultJpaCallbacks

import javax.persistence.PostUpdate; //导入依赖的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.PostUpdate; //导入依赖的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.PostUpdate; //导入依赖的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: setChildIds

import javax.persistence.PostUpdate; //导入依赖的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

示例8: setChildIds

import javax.persistence.PostUpdate; //导入依赖的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

示例9: setChildIds

import javax.persistence.PostUpdate; //导入依赖的package包/类
@PostPersist
@PostUpdate
public void setChildIds() {
    if (getCertificates() != null) {
        getCertificates().forEach(this::assignToCert);
    }
}
 
开发者ID:MaritimeConnectivityPlatform,项目名称:IdentityRegistry,代码行数:8,代码来源:CertificateModel.java

示例10: postUpdateLifecycleMethod

import javax.persistence.PostUpdate; //导入依赖的package包/类
@PostUpdate
public void postUpdateLifecycleMethod() {
    postUpdateCount++;
    if (postUpdateCount != preUpdateCount) {
        throw new IllegalStateException("postUpdateCount(" + postUpdateCount + ") != preUpdateCount(" + preUpdateCount + ")");
    }
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:8,代码来源:FieldAccessAnnotationTestBean.java

示例11: customerUpdated

import javax.persistence.PostUpdate; //导入依赖的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

示例12: customerUpdated

import javax.persistence.PostUpdate; //导入依赖的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

示例13: postLoadAttributes

import javax.persistence.PostUpdate; //导入依赖的package包/类
@PostLoad
@PostUpdate
@PostPersist
private void postLoadAttributes() {
  if (dbAttributes != null) {
    attributes =
        dbAttributes.values().stream().collect(toMap(attr -> attr.name, attr -> attr.values));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:10,代码来源:ProjectConfigImpl.java

示例14: determineSharedParentStatus

import javax.persistence.PostUpdate; //导入依赖的package包/类
@PostLoad
@PostUpdate
public void determineSharedParentStatus() {
    Rubric rubric = getRubric();
    if (rubric != null && rubric.getMetadata().isShared()) {
        getMetadata().setShared(true);
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:Criterion.java

示例15: determineLockStatus

import javax.persistence.PostUpdate; //导入依赖的package包/类
@PostLoad
@PostUpdate
public void determineLockStatus() {
    if (getToolItemAssociations() != null && getToolItemAssociations().size() > 0) {
        getMetadata().setLocked(true);
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:8,代码来源:Rubric.java


注:本文中的javax.persistence.PostUpdate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。