javax.persistence.PrePersist Java Examples
The following examples show how to use
javax.persistence.PrePersist.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Stock.java From cloud-espm-v2 with Apache License 2.0 | 6 votes |
@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(); } }
Example #2
Source File: SalesOrderHeader.java From cloud-espm-v2 with Apache License 2.0 | 6 votes |
@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); } }
Example #3
Source File: JpaObject.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@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(); }
Example #4
Source File: ConsumerAudit.java From apollo with Apache License 2.0 | 5 votes |
@PrePersist protected void prePersist() { if (this.dataChangeCreatedTime == null) { this.dataChangeCreatedTime = new Date(); } if (this.dataChangeLastModifiedTime == null) { dataChangeLastModifiedTime = this.dataChangeCreatedTime; } }
Example #5
Source File: AbstractEntity.java From galeb with Apache License 2.0 | 5 votes |
@PrePersist private void onCreate() { createdAt = new Date(); createdBy = getCurrentAuditor(); lastModifiedAt = createdAt; lastModifiedBy = createdBy; saveOnly = false; }
Example #6
Source File: GriffinMeasure.java From griffin with Apache License 2.0 | 5 votes |
@PrePersist @PreUpdate public void save() throws JsonProcessingException { super.save(); if (ruleDescriptionMap != null) { this.ruleDescription = JsonUtil.toJson(ruleDescriptionMap); } }
Example #7
Source File: AuditEntityListener.java From javaee8-jaxrs-sample with GNU General Public License v3.0 | 5 votes |
@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()); } } }
Example #8
Source File: Product.java From java-platform with Apache License 2.0 | 5 votes |
/** * 持久化前处理 */ @PrePersist public void prePersist() { if (getStock() == null) { setAllocatedStock(0); } setScore(0F); }
Example #9
Source File: PluginMysqlInstance.java From wecube-platform with Apache License 2.0 | 5 votes |
@PrePersist public void initId() { if (null == this.id || this.id.trim().equals("")) { this.id = DomainIdBuilder.buildDomainId(null != pluginPackage ? pluginPackage.getId() : null, schemaName, username); } }
Example #10
Source File: WarpDbCRUDAndCallbackTest.java From warpdb with Apache License 2.0 | 5 votes |
@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); }
Example #11
Source File: Measure.java From griffin with Apache License 2.0 | 5 votes |
@PrePersist @PreUpdate public void save() throws JsonProcessingException { if (sinksList != null) { this.sinks = JsonUtil.toJson(sinksList); } }
Example #12
Source File: StreamingPreProcess.java From griffin with Apache License 2.0 | 5 votes |
@PrePersist @PreUpdate public void save() throws JsonProcessingException { if (detailsMap != null) { this.details = JsonUtil.toJson(detailsMap); } }
Example #13
Source File: Rule.java From griffin with Apache License 2.0 | 5 votes |
@PrePersist @PreUpdate public void save() throws JsonProcessingException { if (detailsMap != null) { this.details = JsonUtil.toJson(detailsMap); } if (outList != null) { this.out = JsonUtil.toJson(outList); } }
Example #14
Source File: DataConnector.java From griffin with Apache License 2.0 | 5 votes |
@PrePersist @PreUpdate public void save() throws JsonProcessingException { if (configMap != null) { this.config = JsonUtil.toJson(configMap); } }
Example #15
Source File: PasswordFile.java From zhcet-web with Apache License 2.0 | 5 votes |
@PrePersist public void setCreatedTime() { if (createdTime != null) return; createdTime = LocalDateTime.now(); }
Example #16
Source File: AuditEntityListener.java From javaee8-jsf-sample with GNU General Public License v3.0 | 5 votes |
@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()); } } }
Example #17
Source File: BaseEntity.java From tianti with Apache License 2.0 | 5 votes |
@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); } }
Example #18
Source File: ACLEntryImpl.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <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(); }
Example #19
Source File: User.java From warpdb with Apache License 2.0 | 5 votes |
@PrePersist void prePersist() { callbacks.add(PrePersist.class); if (this.id == null) { this.id = nextId(); } this.createdAt = this.updatedAt = System.currentTimeMillis(); }
Example #20
Source File: UtcTimeLongEntityListener.java From microservice_coffeeshop with Apache License 2.0 | 5 votes |
@PrePersist public void touchForCreate(UtcTimeLongIdEntity entity) { if (entity.getUtcCreate() == null || entity.getUtcModified() == null) { Instant now = Instant.now(); entity.setUtcCreate(now); entity.setUtcModified(now); } }
Example #21
Source File: AccessToken.java From heimdall with Apache License 2.0 | 5 votes |
@PrePersist private void initValuesPersist() { status = (status == null) ? Status.ACTIVE : status; creationDate = LocalDateTime.now(); code = code.trim(); }
Example #22
Source File: AffectedLibrary.java From steady with Apache License 2.0 | 5 votes |
/** * <p>prePersist.</p> */ @PrePersist public void prePersist() { if(this.getCreatedAt()==null) { this.setCreatedAt(Calendar.getInstance()); } if(this.getModifiedAt()==null) { this.setModifiedAt(Calendar.getInstance()); } }
Example #23
Source File: Library.java From steady with Apache License 2.0 | 5 votes |
/** * <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; } }
Example #24
Source File: GoalExecution.java From steady with Apache License 2.0 | 5 votes |
/** * Sets {@link GoalExecution#createdAt}. */ @PrePersist public void prePersist() { if(this.getCreatedAt()==null) { this.setCreatedAt(Calendar.getInstance()); } }
Example #25
Source File: Bug.java From steady with Apache License 2.0 | 5 votes |
/** * <p>prePersist.</p> */ @PrePersist public void prePersist() { if(this.getCreatedAt()==null) this.setCreatedAt(Calendar.getInstance()); this.setModifiedAt(Calendar.getInstance()); }
Example #26
Source File: Dependency.java From steady with Apache License 2.0 | 5 votes |
/** * <p>prePersist.</p> */ @PrePersist public void prePersist() { if(this.getTraced()==null) { this.setTraced(false); } }
Example #27
Source File: Tenant.java From steady with Apache License 2.0 | 5 votes |
/** * <p>prePersist.</p> */ @PrePersist public void prePersist() { if(this.getCreatedAt()==null) this.setCreatedAt(Calendar.getInstance()); this.setLastModified(Calendar.getInstance()); }
Example #28
Source File: Application.java From steady with Apache License 2.0 | 5 votes |
/** * <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()); }
Example #29
Source File: Space.java From steady with Apache License 2.0 | 5 votes |
/** * <p>prePersist.</p> */ @PrePersist public void prePersist() { if(this.getCreatedAt()==null) this.setCreatedAt(Calendar.getInstance()); this.setLastModified(Calendar.getInstance()); }
Example #30
Source File: Order.java From java-platform with Apache License 2.0 | 5 votes |
/** * 持久化前处理 */ @PrePersist public void prePersist() { if (getArea() != null) { setAreaName(getArea().getFullName()); } if (getPaymentMethod() != null) { setPaymentMethodName(getPaymentMethod().getName()); } if (getShippingMethod() != null) { setShippingMethodName(getShippingMethod().getName()); } }