javax.persistence.PreRemove Java Examples
The following examples show how to use
javax.persistence.PreRemove.
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: ShippingMethod.java From java-platform with Apache License 2.0 | 6 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<PaymentMethod> paymentMethods = getPaymentMethods(); if (paymentMethods != null) { for (PaymentMethod paymentMethod : paymentMethods) { paymentMethod.getShippingMethods().remove(this); } } Set<Order> orders = getOrders(); if (orders != null) { for (Order order : orders) { order.setShippingMethod(null); } } }
Example #2
Source File: Brand.java From java-platform with Apache License 2.0 | 6 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Product> products = getProducts(); if (products != null) { for (Product product : products) { product.setBrand(null); } } Set<ProductCategory> productCategories = getProductCategories(); if (productCategories != null) { for (ProductCategory productCategory : productCategories) { productCategory.getBrands().remove(this); } } Set<Promotion> promotions = getPromotions(); if (promotions != null) { for (Promotion promotion : promotions) { promotion.getBrands().remove(this); } } }
Example #3
Source File: Product.java From java-platform with Apache License 2.0 | 6 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { // Set<User> favoriteUsers = getFavoriteUsers(); // if (favoriteUsers != null) { // for (User favoriteMember : favoriteUsers) { // favoriteMember.getFavoriteProducts().remove(this); // } // } Set<Promotion> promotions = getPromotions(); if (promotions != null) { for (Promotion promotion : promotions) { promotion.getProducts().remove(this); } } Set<OrderItem> orderItems = getOrderItems(); if (orderItems != null) { for (OrderItem orderItem : orderItems) { orderItem.setProduct(null); } } }
Example #4
Source File: Coupon.java From java-platform with Apache License 2.0 | 6 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Promotion> promotions = getPromotions(); if (promotions != null) { for (Promotion promotion : promotions) { promotion.getCoupons().remove(this); } } List<Order> orders = getOrders(); if (orders != null) { for (Order order : orders) { order.getCoupons().remove(this); } } }
Example #5
Source File: ChangeStateJpaListener.java From microservices-transactions-tcc with Apache License 2.0 | 5 votes |
@PreRemove void onPreRemove(Object o) { String txId = (String)ThreadLocalContext.get(CompositeTransactionParticipantService.CURRENT_TRANSACTION_KEY); if (null == txId){ LOG.info("onPreRemove outside any transaction"); } else { LOG.info("onPreRemove inside transaction [{}]", txId); enlist(o, EntityCommand.Action.DELETE, txId); } }
Example #6
Source File: DeliveryCorp.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<ShippingMethod> shippingMethods = getShippingMethods(); if (shippingMethods != null) { for (ShippingMethod shippingMethod : shippingMethods) { shippingMethod.setDefaultDeliveryCorp(null); } } }
Example #7
Source File: PaymentMethod.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Order> orders = getOrders(); if (orders != null) { for (Order order : orders) { order.setPaymentMethod(null); } } }
Example #8
Source File: Order.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Deposit> deposits = getDeposits(); if (deposits != null) { for (Deposit deposit : deposits) { deposit.setOrder(null); } } }
Example #9
Source File: Payment.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { if (getDeposit() != null) { getDeposit().setPayment(null); } }
Example #10
Source File: ProductTag.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Product> products = getProducts(); if (products != null) { for (Product product : products) { product.getTags().remove(this); } } }
Example #11
Source File: ProductCategory.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Promotion> promotions = getPromotions(); if (promotions != null) { for (Promotion promotion : promotions) { promotion.getProductCategories().remove(this); } } }
Example #12
Source File: ArticleTag.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Article> articles = getArticles(); if (articles != null) { for (Article article : articles) { article.getTags().remove(this); } } }
Example #13
Source File: PersistenceUser.java From TeaStore with Apache License 2.0 | 5 votes |
/** * Delete orders and order items. */ @PreRemove private void deleteOrders() { EntityManager em = UserRepository.REPOSITORY.getEMF().createEntityManager(); try { em.getTransaction().begin(); em.createQuery("DELETE FROM PersistenceOrderItem oi WHERE oi.order.user = :user") .setParameter("user", this).executeUpdate(); em.createQuery("DELETE FROM PersistenceOrder o WHERE o.user = :user") .setParameter("user", this).executeUpdate(); em.getTransaction().commit(); } finally { em.close(); } }
Example #14
Source File: PersistenceOrder.java From TeaStore with Apache License 2.0 | 5 votes |
/** * Delete orders and order items. */ @PreRemove private void deleteOrders() { EntityManager em = OrderRepository.REPOSITORY.getEMF().createEntityManager(); try { em.getTransaction().begin(); em.createQuery("DELETE FROM PersistenceOrderItem oi WHERE oi.order = :order") .setParameter("order", this).executeUpdate(); em.getTransaction().commit(); } finally { em.close(); } }
Example #15
Source File: Rank.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { Set<Promotion> promotions = getPromotions(); if (promotions != null) { for (Promotion promotion : promotions) { promotion.getMemberRanks().remove(this); } } }
Example #16
Source File: CouponCode.java From java-platform with Apache License 2.0 | 5 votes |
/** * 删除前处理 */ @PreRemove public void preRemove() { if (getOrder() != null) { getOrder().setCouponCode(null); } }
Example #17
Source File: WarpDbCRUDAndCallbackTest.java From warpdb with Apache License 2.0 | 5 votes |
@Test public void testRemove() throws Exception { User user = new User(); user.name = "Michael"; user.email = "[email protected]"; warpdb.insert(user); warpdb.remove(user); assertTrue(user.callbacks.contains(PreRemove.class)); assertTrue(user.callbacks.contains(PostRemove.class)); assertNull(warpdb.fetch(User.class, user.id)); }
Example #18
Source File: Artifact.java From pnc with Apache License 2.0 | 5 votes |
@PreRemove public void preRemove() { if (artifactQuality != ArtifactQuality.TEMPORARY && artifactQuality != ArtifactQuality.DELETED) { throw new PersistenceException( "The non-temporary artifacts cannot be deleted! Only deletion of temporary artifacts is supported "); } }
Example #19
Source File: AuditTrailListener.java From tutorials with MIT License | 5 votes |
@PrePersist @PreUpdate @PreRemove private void beforeAnyUpdate(User user) { if (user.getId() == 0) { log.info("[USER AUDIT] About to add a user"); } else { log.info("[USER AUDIT] About to update/delete user: " + user.getId()); } }
Example #20
Source File: WarpDbCRUDAndCallbackTest.java From warpdb with Apache License 2.0 | 5 votes |
@Test public void testRemoveBeans() throws Exception { User[] users = new User[5]; for (int i = 0; i < users.length; i++) { User user = new User(); user.name = "Mr No." + i; user.email = "no." + i + "@somewhere.org"; users[i] = user; } warpdb.insert(Arrays.asList(users)); warpdb.remove(Arrays.asList(users)); assertTrue(users[0].callbacks.contains(PreRemove.class)); assertTrue(users[0].callbacks.contains(PostRemove.class)); assertNull(warpdb.fetch(User.class, users[0].id)); }
Example #21
Source File: EntityCallbacksListener.java From nomulus with Apache License 2.0 | 4 votes |
@PreRemove void preRemove(Object entity) { EntityCallbackExecutor.create(PreRemove.class).execute(entity, entity.getClass()); }
Example #22
Source File: EntityCallbacksListenerTest.java From nomulus with Apache License 2.0 | 4 votes |
@PreRemove void entityEmbeddedNestedPreRemove() { entityEmbeddedNestedPreRemove++; }
Example #23
Source File: Bar.java From tutorials with MIT License | 4 votes |
@PreRemove public void onPreRemove() { logger.info("@PreRemove"); audit(OPERATION.DELETE); }
Example #24
Source File: Role.java From spring-microservice-boilerplate with MIT License | 4 votes |
@PreRemove private void removeRolesFromUsers() { users.forEach(user -> user.getRoles().remove(this)); }
Example #25
Source File: Resource.java From spring-microservice-boilerplate with MIT License | 4 votes |
@PreRemove private void removeResourcesFromRoles() { roles.forEach(role -> role.getResources().remove(this)); }
Example #26
Source File: BuildConfiguration.java From pnc with Apache License 2.0 | 4 votes |
@PreRemove private void removeConfigurationFromSets() { for (BuildConfigurationSet bcs : buildConfigurationSets) { bcs.getBuildConfigurations().remove(this); } }
Example #27
Source File: BuildRecord.java From pnc with Apache License 2.0 | 4 votes |
@PreRemove public void preRemove() { if (this.temporaryBuild == false) throw new PersistenceException( "The non-temporary builds cannot be deleted! Only deletion of temporary builds is supported"); }
Example #28
Source File: BuildConfigSetRecord.java From pnc with Apache License 2.0 | 4 votes |
@PreRemove public void preRemove() { if (this.temporaryBuild == false) throw new PersistenceException( "The non-temporary builds cannot be deleted! Only deletion of temporary builds is supported"); }
Example #29
Source File: User.java From tutorials with MIT License | 4 votes |
@PreRemove public void logUserRemovalAttempt() { log.info("Attempting to delete user: " + userName); }
Example #30
Source File: EagerTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PreRemove void preRemove() { preRemoved = true; }