类javax.persistence.PostPersist源码实例Demo

下面列出了怎么用javax.persistence.PostPersist的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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));
}
 
@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);
}
 
源代码3 项目: warpdb   文件: WarpDbCRUDAndCallbackTest.java
@Test
public void testInsert() throws Exception {
	User user = new User();
	user.name = "Michael";
	user.email = "[email protected]";
	warpdb.insert(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.0);
}
 
源代码4 项目: che   文件: ProjectConfigImpl.java
@PostLoad
@PostUpdate
@PostPersist
private void postLoadAttributes() {
  if (dbAttributes != null) {
    attributes =
        dbAttributes.values().stream().collect(toMap(attr -> attr.name, attr -> attr.values));
  }
}
 
@PostPersist
public void startSituationTriggerInstanceObserver(final SituationTriggerInstance instance) {
    final SituationTriggerInstanceObserver obs = new SituationTriggerInstanceObserver(instance);
    // this performs service injection for us
    SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(obs);

    SituationTriggerInstanceListener.obs.add(obs);
    new Thread(obs).start();
}
 
源代码6 项目: hermes   文件: UserServiceImpl.java
@Override
@PostPersist
public void signUp(User user) throws Exception {
	user.setType(Type.CLIENT);
	user.setStatus(Status.INACTIVATE);
	String pwd = encode(user.getSignPassword());
	user.setSignPassword(pwd);// 密码加密
	userRepository.save(user);
	Logger.info("用户成功 ID=" + user.getId());
	saveUser(user);
}
 
源代码7 项目: 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);
}
 
源代码8 项目: hibernate-reactive   文件: EagerTest.java
@PostPersist
void postPersist() {
	postPersisted = true;
}
 
源代码9 项目: hibernate-reactive   文件: DB2BasicTest.java
@PostPersist
void postPersist() {
	postPersisted = true;
}
 
源代码10 项目: hibernate-reactive   文件: BatchFetchTest.java
@PostPersist
void postPersist() {
	postPersisted = true;
}
 
源代码11 项目: hibernate-reactive   文件: SubselectFetchTest.java
@PostPersist
void postPersist() {
	postPersisted = true;
}
 
源代码12 项目: hibernate-reactive   文件: CascadeTest.java
@PostPersist
void postPersist() {
	postPersisted = true;
}
 
源代码13 项目: Java-EE-8-and-Angular   文件: TaskAudit.java
@PostPersist
public void trackChanges(MappedSuperEntity entity) {
    System.out.println("PostPersist of " + entity);    
}
 
@PostPersist
public void createObject(BaseEntity o) {
    //System.out.println("create object :"+ o);
    jmsTool.sendMessage(JMSType.CREATE, o);
}
 
源代码15 项目: warpdb   文件: Mapper.java
public Mapper(Class<T> clazz) {
	super();
	List<AccessibleProperty> all = getPropertiesIncludeHierarchy(clazz);
	// check duplicate name:
	Set<String> propertyNamesSet = new HashSet<>();
	for (String propertyName : all.stream().map((p) -> {
		return p.propertyName;
	}).toArray(String[]::new)) {
		if (!propertyNamesSet.add(propertyName.toLowerCase())) {
			throw new ConfigurationException(
					"Duplicate property name found: " + propertyName + " in class: " + clazz.getName());
		}
	}
	Set<String> columnNamesSet = new HashSet<>();
	for (String columnName : all.stream().map((p) -> {
		return p.columnName;
	}).toArray(String[]::new)) {
		if (!columnNamesSet.add(columnName.toLowerCase())) {
			throw new ConfigurationException("Duplicate column name found: " + columnName);
		}
	}
	// check @Id:
	AccessibleProperty[] ids = all.stream().filter((p) -> {
		return p.isId();
	}).sorted((p1, p2) -> {
		return p1.columnName.compareTo(p2.columnName);
	}).toArray(AccessibleProperty[]::new);
	if (ids.length == 0) {
		throw new ConfigurationException("No @Id found.");
	}
	if (ids.length > 1 && all.stream().filter((p) -> {
		return p.isId() && p.isIdentityId();
	}).count() > 0) {
		throw new ConfigurationException("Mutiple @Id cannot be identity.");
	}
	// get @Version:
	AccessibleProperty[] versions = all.stream().filter((p) -> {
		return p.isVersion();
	}).toArray(AccessibleProperty[]::new);
	if (versions.length > 1) {
		throw new ConfigurationException("Multiple @Version found.");
	}
	this.version = versions.length == 0 ? null : versions[0];

	this.allProperties = all;
	this.allPropertiesMap = buildPropertiesMap(this.allProperties);

	this.insertableProperties = all.stream().filter((p) -> {
		if (p.isIdentityId()) {
			return false;
		}
		return p.isInsertable();
	}).collect(Collectors.toList());

	this.updatableProperties = all.stream().filter((p) -> {
		return p.isUpdatable();
	}).collect(Collectors.toList());

	this.updatablePropertiesMap = buildPropertiesMap(this.updatableProperties);

	// init:
	this.ids = ids;
	this.entityClass = clazz;
	this.tableName = getTableName(clazz);

	this.whereIdsEquals = String.join(" AND ",
			Arrays.stream(this.ids).map(id -> id.columnName + " = ?").toArray(String[]::new));

	this.selectSQL = "SELECT * FROM " + this.tableName + " WHERE " + this.whereIdsEquals;

	String insertPostfix = this.tableName + " (" + String.join(", ", this.insertableProperties.stream().map((p) -> {
		return p.columnName;
	}).toArray(String[]::new)) + ") VALUES (" + numOfQuestions(this.insertableProperties.size()) + ")";
	this.insertSQL = "INSERT INTO " + insertPostfix;
	this.insertIgnoreSQL = "INSERT IGNORE INTO " + insertPostfix;

	this.updateSQL = "UPDATE " + this.tableName + " SET "
			+ String.join(", ", this.updatableProperties.stream().map((p) -> {
				return p.columnName + " = ?";
			}).toArray(String[]::new)) + " WHERE " + this.whereIdsEquals;

	this.deleteSQL = "DELETE FROM " + this.tableName + " WHERE " + this.whereIdsEquals;

	this.rowMapper = new BeanRowMapper<>(this.entityClass, this.allProperties);

	List<Method> methods = this.findMethods(clazz);
	this.prePersist = findListener(methods, PrePersist.class);
	this.preUpdate = findListener(methods, PreUpdate.class);
	this.preRemove = findListener(methods, PreRemove.class);
	this.postLoad = findListener(methods, PostLoad.class);
	this.postPersist = findListener(methods, PostPersist.class);
	this.postUpdate = findListener(methods, PostUpdate.class);
	this.postRemove = findListener(methods, PostRemove.class);
}
 
源代码16 项目: warpdb   文件: User.java
@PostPersist
void postPersist() {
	callbacks.add(PostPersist.class);
}
 
源代码17 项目: nomulus   文件: EntityCallbacksListener.java
@PostPersist
void postPersist(Object entity) {
  EntityCallbackExecutor.create(PostPersist.class).execute(entity, entity.getClass());
}
 
源代码18 项目: nomulus   文件: EntityCallbacksListenerTest.java
@PostPersist
void entityEmbeddedNestedPostPersist() {
  entityEmbeddedNestedPostPersist++;
}
 
源代码19 项目: dolphin-platform   文件: AbstractEntity.java
@PostPersist
public void onPersist() {
    PersistenceListenerManager.getInstance().firePersisted(this);
}
 
源代码20 项目: olingo-odata2   文件: SalesOrderHeader.java
@PostPersist
public void defaultValues() {
  if (creationDate == null) {
    setCreationDate(creationDate);
  }
}
 
源代码21 项目: syncope   文件: JPAJSONAnyObjectListener.java
@PostPersist
@PostUpdate
public void readAfterSave(final JPAJSONAnyObject anyObject) {
    super.json2list(anyObject, true);
}
 
源代码22 项目: syncope   文件: JPAJSONGroupListener.java
@PostPersist
@PostUpdate
public void readAfterSave(final JPAJSONGroup group) {
    super.json2list(group, true);
}
 
源代码23 项目: syncope   文件: JPAJSONUserListener.java
@PostPersist
@PostUpdate
public void readAfterSave(final JPAJSONUser user) {
    super.json2list(user, true);
}
 
源代码24 项目: syncope   文件: JPAJSONLinkedAccountListener.java
@PostPersist
@PostUpdate
public void readAfterSave(final JPAJSONLinkedAccount account) {
    super.json2list(account, true);
}
 
源代码25 项目: hermes   文件: Model.java
/**
 * 持久化后调用
 */
@PostPersist
protected void onPostPersist() {
	Logger.info("user '%s' insert data '%s - %s'.", getCreator(), this.getClass().getSimpleName(), getId());
}
 
源代码26 项目: hibernate-demos   文件: TestListener.java
@PostPersist public void onPostPersist(TestEntity entity) {
    testService.addTestEntityName(entity.name);
}
 
源代码27 项目: tutorials   文件: AuditTrailListener.java
@PostPersist
@PostUpdate
@PostRemove
private void afterAnyUpdate(User user) {
    log.info("[USER AUDIT] add/update/delete complete for user: " + user.getId());
}
 
源代码28 项目: tutorials   文件: User.java
@PostPersist
public void logNewUserAdded() {
    log.info("Added user '" + userName + "' with ID: " + id);
}
 
源代码29 项目: apiman   文件: GatewayBean.java
@PostPersist @PostUpdate @PostLoad
protected void decryptData() {
    // Encrypt the endpoint properties.
    configuration = CurrentDataEncrypter.instance.decrypt(configuration, new DataEncryptionContext());
}
 
源代码30 项目: hawkbit   文件: EntityInterceptorListener.java
/**
 * Callback for lifecyle event <i>post persist</i>.
 *
 * @param entity
 *            the JPA entity which this listener is associated with
 */
@PostPersist
public void postPersist(final Object entity) {
    notifyAll(interceptor -> interceptor.postPersist(entity));
}
 
 类所在包
 类方法
 同包方法