类javax.persistence.PrePersist源码实例Demo

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

源代码1 项目: cloud-espm-v2   文件: Stock.java
@PrePersist
@PreUpdate
private void persist() {
	EntityManagerFactory emf = Utility.getEntityManagerFactory();
	EntityManager em = emf.createEntityManager();
	try {
		em.getTransaction().begin();
		if (this.quantity.compareTo(this.minStock) < 0) {
			this.quantityLessMin = true;
		} else {
			this.quantityLessMin = false;
		}

		em.getTransaction().commit();
	} finally {
		em.close();
	}
}
 
源代码2 项目: o2oa   文件: JpaObject.java
@PrePersist
public void prePersist() throws Exception {
	if (StringUtils.isEmpty(this.getId())) {
		throw new Exception("basePrePersist error, id is empty, entity class:" + this.getClass().getName()
				+ ", entity content:" + XGsonBuilder.toJson(this) + ".");
	}
	Date date = new Date();
	if (null == this.getCreateTime()) {
		this.setCreateTime(date);
	}
	this.setUpdateTime(date);
	if (StringUtils.isEmpty(this.getSequence())) {
		this.setSequence(StringUtils.join(DateTools.compact(this.getCreateTime()), this.getId()));
	}
	this.onPersist();
}
 
源代码3 项目: cloud-espm-v2   文件: SalesOrderHeader.java
@PrePersist
private void persist() {
	Calendar cal = Calendar.getInstance();
	Date date = new Date();
	cal.setTime(date);
	this.lifeCycleStatus = "N";
	this.lifeCycleStatusName = "New";
	int itemNumber = 10;
	this.netAmount = new BigDecimal("0.00");
	this.taxAmount = new BigDecimal("0.00");
	this.grossAmount = new BigDecimal("0.00");
	this.createdAt = cal;
	for (SalesOrderItem item : salesOrderItems) {
		item.setSalesOrderId(this.getSalesOrderId());
		item.setItemNumber(itemNumber);
		itemNumber += 10;
		item.persist();
		this.netAmount = this.netAmount.add(item.getNetAmount())
				.setScale(3);
		this.taxAmount = this.taxAmount.add(item.getTaxAmount())
				.setScale(3);
		this.grossAmount = this.grossAmount.add(item.getGrossAmount())
				.setScale(3);
	}
}
 
源代码4 项目: wecube-platform   文件: PluginMysqlInstance.java
@PrePersist
public void initId() {
    if (null == this.id || this.id.trim().equals("")) {
        this.id = DomainIdBuilder.buildDomainId(null != pluginPackage ? pluginPackage.getId() : null, schemaName,
                username);
    }
}
 
源代码5 项目: java-platform   文件: Product.java
/**
 * 持久化前处理
 */
@PrePersist
public void prePersist() {
	if (getStock() == null) {
		setAllocatedStock(0);
	}
	setScore(0F);
}
 
源代码6 项目: warpdb   文件: User.java
@PrePersist
void prePersist() {
	callbacks.add(PrePersist.class);
	if (this.id == null) {
		this.id = nextId();
	}
	this.createdAt = this.updatedAt = System.currentTimeMillis();
}
 
@PrePersist
public void touchForCreate(UtcTimeLongIdEntity entity) {
    if (entity.getUtcCreate() == null || entity.getUtcModified() == null) {
        Instant now = Instant.now();
        entity.setUtcCreate(now);
        entity.setUtcModified(now);
    }
}
 
源代码8 项目: steady   文件: AffectedLibrary.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null) {
		this.setCreatedAt(Calendar.getInstance());
	}
	if(this.getModifiedAt()==null) {
		this.setModifiedAt(Calendar.getInstance());
	}
}
 
源代码9 项目: steady   文件: Library.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null) {
		this.setCreatedAt(Calendar.getInstance());
	}
	if(this.getModifiedAt()==null) {
		this.setModifiedAt(Calendar.getInstance());
	}
	// If uploaded by old client (<3.0.0), the digest also must be set
	if(this.sha1!=null && (this.digest==null || this.digestAlgorithm==null)) {
		this.digest = this.sha1;
		this.digestAlgorithm = DigestAlgorithm.SHA1;
	}
}
 
源代码10 项目: steady   文件: GoalExecution.java
/**
 * Sets {@link GoalExecution#createdAt}.
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null) {
		this.setCreatedAt(Calendar.getInstance());
	}
}
 
源代码11 项目: steady   文件: Bug.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null)
		this.setCreatedAt(Calendar.getInstance());
	this.setModifiedAt(Calendar.getInstance());
}
 
源代码12 项目: steady   文件: Dependency.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getTraced()==null) {
		this.setTraced(false);
	}
}
 
源代码13 项目: steady   文件: Tenant.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null)
		this.setCreatedAt(Calendar.getInstance());
	this.setLastModified(Calendar.getInstance());
}
 
源代码14 项目: steady   文件: Application.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null) {
		this.setCreatedAt(Calendar.getInstance());
	}
	this.setModifiedAt(Calendar.getInstance());
	this.setLastScan(Calendar.getInstance());
	this.setLastVulnChange(Calendar.getInstance());
}
 
源代码15 项目: steady   文件: Space.java
/**
 * <p>prePersist.</p>
 */
@PrePersist
public void prePersist() {
	if(this.getCreatedAt()==null)
		this.setCreatedAt(Calendar.getInstance());
	this.setLastModified(Calendar.getInstance());
}
 
源代码16 项目: heimdall   文件: AccessToken.java
@PrePersist
private void initValuesPersist() {

     status = (status == null) ? Status.ACTIVE : status;

     creationDate = LocalDateTime.now();
     code = code.trim();
}
 
源代码17 项目: javaee8-jsf-sample   文件: AuditEntityListener.java
@PrePersist
public void beforePersist(Object entity) {
    if (entity instanceof AbstractAuditableEntity) {
        AbstractAuditableEntity o = (AbstractAuditableEntity) entity;
        final LocalDateTime now = LocalDateTime.now();
        o.setCreatedDate(now);
        o.setLastModifiedDate(now);

        if (o.getCreatedBy() == null) {
            o.setCreatedBy(currentUser());
        }
    }
}
 
源代码18 项目: griffin   文件: SegmentPredicate.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    if (configMap != null) {
        this.config = JsonUtil.toJson(configMap);
    }
}
 
源代码19 项目: 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);
}
 
源代码20 项目: griffin   文件: Measure.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    if (sinksList != null) {
        this.sinks = JsonUtil.toJson(sinksList);
    }
}
 
源代码21 项目: griffin   文件: StreamingPreProcess.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    if (detailsMap != null) {
        this.details = JsonUtil.toJson(detailsMap);
    }
}
 
源代码22 项目: griffin   文件: Rule.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    if (detailsMap != null) {
        this.details = JsonUtil.toJson(detailsMap);
    }
    if (outList != null) {
        this.out = JsonUtil.toJson(outList);
    }
}
 
源代码23 项目: griffin   文件: DataConnector.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    if (configMap != null) {
        this.config = JsonUtil.toJson(configMap);
    }
}
 
源代码24 项目: griffin   文件: GriffinMeasure.java
@PrePersist
@PreUpdate
public void save() throws JsonProcessingException {
    super.save();
    if (ruleDescriptionMap != null) {
        this.ruleDescription = JsonUtil.toJson(ruleDescriptionMap);
    }
}
 
源代码25 项目: zhcet-web   文件: PasswordFile.java
@PrePersist
public void setCreatedTime() {
    if (createdTime != null)
        return;

    createdTime = LocalDateTime.now();
}
 
源代码26 项目: java-platform   文件: Order.java
/**
 * 持久化前处理
 */
@PrePersist
public void prePersist() {
	if (getArea() != null) {
		setAreaName(getArea().getFullName());
	}
	if (getPaymentMethod() != null) {
		setPaymentMethodName(getPaymentMethod().getName());
	}
	if (getShippingMethod() != null) {
		setShippingMethodName(getShippingMethod().getName());
	}
}
 
源代码27 项目: galeb   文件: AbstractEntity.java
@PrePersist
private void onCreate() {
    createdAt = new Date();
    createdBy = getCurrentAuditor();
    lastModifiedAt = createdAt;
    lastModifiedBy = createdBy;
    saveOnly = false;
}
 
源代码28 项目: lams   文件: ACLEntryImpl.java
/**
 * <p>
 * Method called by the JPA layer before persisting the fields.
 * </p>
 */
@PrePersist
@SuppressWarnings("unused")
private void setPersistentFields()
{
   if (this.permission != null)
      this.bitMask = this.permission.getMaskValue();
}
 
源代码29 项目: tianti   文件: BaseEntity.java
@PrePersist
  public void prePersist() {
if(this.createDate == null){
	this.setCreateDate(new Date());
}
this.setUpdateDate(new Date());
if(StringUtils.isBlank(this.getDeleteFlag())){
	this.setDeleteFlag(BaseEntity.DELETE_FLAG_NORMAL);	
}
  }
 
源代码30 项目: celerio-angular-quickstart   文件: User.java
@PrePersist
protected void prePersist() {
    if (AuditContextHolder.audit()) {
        setCreationAuthor(AuditContextHolder.username());
        setCreationDate(Instant.now());

    }
}
 
 类所在包
 同包方法