javax.persistence.PostRemove Java Examples
The following examples show how to use
javax.persistence.PostRemove.
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: PersistenceOrderItem.java From TeaStore with Apache License 2.0 | 5 votes |
/** * Clear products and orders from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceProduct.class); CacheManager.MANAGER.clearCache(PersistenceOrder.class); CacheManager.MANAGER.clearRemoteCache(PersistenceOrderItem.class); }
Example #2
Source File: PersistenceOrder.java From TeaStore with Apache License 2.0 | 5 votes |
/** * Clear users and order items from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceUser.class); CacheManager.MANAGER.clearCache(PersistenceOrderItem.class); CacheManager.MANAGER.clearRemoteCache(PersistenceOrder.class); }
Example #3
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 #4
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 #5
Source File: Mapper.java From warpdb with Apache License 2.0 | 4 votes |
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); }
Example #6
Source File: User.java From tutorials with MIT License | 4 votes |
@PostRemove public void logUserRemoval() { log.info("Deleted user: " + userName); }
Example #7
Source File: AuditTrailListener.java From tutorials with MIT License | 4 votes |
@PostPersist @PostUpdate @PostRemove private void afterAnyUpdate(User user) { log.info("[USER AUDIT] add/update/delete complete for user: " + user.getId()); }
Example #8
Source File: AbstractEntity.java From dolphin-platform with Apache License 2.0 | 4 votes |
@PostRemove public void onRemove() { PersistenceListenerManager.getInstance().fireRemoved(this); }
Example #9
Source File: EntityCallbacksListenerTest.java From nomulus with Apache License 2.0 | 4 votes |
@PostRemove void entityEmbeddedNestedPostRemove() { entityEmbeddedNestedPostRemove++; }
Example #10
Source File: EntityCallbacksListener.java From nomulus with Apache License 2.0 | 4 votes |
@PostRemove void postRemove(Object entity) { EntityCallbackExecutor.create(PostRemove.class).execute(entity, entity.getClass()); }
Example #11
Source File: User.java From warpdb with Apache License 2.0 | 4 votes |
@PostRemove void postRemove() { callbacks.add(PostRemove.class); }
Example #12
Source File: EagerTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PostRemove void postRemove() { postRemoved = true; }
Example #13
Source File: JPAListener.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 4 votes |
@PostRemove public void removeObject(BaseEntity o) { //System.out.println("create object :"+ o); jmsTool.sendMessage(JMSType.DELETE, o); }
Example #14
Source File: PersistenceCategory.java From TeaStore with Apache License 2.0 | 4 votes |
/** * Clear products from cache to update relationships. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceProduct.class); CacheManager.MANAGER.clearRemoteCache(PersistenceCategory.class); }
Example #15
Source File: PersistenceUser.java From TeaStore with Apache License 2.0 | 4 votes |
/** * Clear users and order items from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceOrder.class); CacheManager.MANAGER.clearRemoteCache(PersistenceUser.class); }
Example #16
Source File: PersistenceProduct.java From TeaStore with Apache License 2.0 | 4 votes |
/** * Clear categories and order items from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceCategory.class); CacheManager.MANAGER.clearRemoteCache(PersistenceProduct.class); }
Example #17
Source File: CascadeTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PostRemove void postRemove() { postRemoved = true; }
Example #18
Source File: SubselectFetchTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PostRemove void postRemove() { postRemoved = true; }
Example #19
Source File: BatchFetchTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PostRemove void postRemove() { postRemoved = true; }
Example #20
Source File: DB2BasicTest.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@PostRemove void postRemove() { postRemoved = true; }
Example #21
Source File: EntityInterceptorListener.java From hawkbit with Eclipse Public License 1.0 | 2 votes |
/** * Callback for lifecyle event <i>post remove</i>. * * @param entity * the JPA entity which this listener is associated with */ @PostRemove public void postRemove(final Object entity) { notifyAll(interceptor -> interceptor.postRemove(entity)); }
Example #22
Source File: DocumentBase.java From rice with Educational Community License v2.0 | 2 votes |
/** * This overridden method is used to delete the {@link DocumentHeader} object due to the system not being able to * manage the {@link DocumentHeader} object via mapping files * * @see org.kuali.rice.krad.bo.PersistableBusinessObjectBase#postRemove() */ @PostRemove protected void postRemove() { KRADServiceLocatorWeb.getDocumentHeaderService().deleteDocumentHeader(getDocumentHeader()); }
Example #23
Source File: PersistableBusinessObjectBase.java From rice with Educational Community License v2.0 | 2 votes |
/** * Default implementation of the JPA {@link PostRemove} hook. This implementation currently does nothing, * however sub-classes can override and implement this method if needed. * * <p>This method is currently invoked by the corresponding OJB {@link #afterDelete(PersistenceBroker)} hook. */ @PostRemove protected void postRemove() { // do nothing }