@PostRemove public void nullifyKey(Object object) { /* * We use reflection to locate the setId method since it's not defined in * any of the base interfaces of the VARS JPAEntities. This is deliberate * we don't normally want developers playing with the setId method. */ if (object instanceof JPAEntity) { Class params[] = {Long.class}; Object args[] = {null}; try { Method method = object.getClass().getDeclaredMethod("setId", params); method.invoke(object, args); } catch (Exception e) { log.error("Failed to set primary key on " + object + " to null", e); } } }
@PostRemove public void removeImagesFromDisk(ImageResource image){ if (image.getHiResImagePath() != null){ delete(image.getHiResImagePath()); } if (image.getLoResImagePath() != null){ delete(image.getLoResImagePath()); } }
/** * 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); }
/** * 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); }
private void processDefaultJpaCallbacks(String instanceCallbackClassName, List<JpaCallbackClass> jpaCallbackClassList) { ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName ); // Process superclass first if available and not excluded if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) { DotName superName = callbackClassInfo.superName(); if ( superName != null ) { processDefaultJpaCallbacks( instanceCallbackClassName, jpaCallbackClassList ); } } String callbackClassName = callbackClassInfo.name().toString(); Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>(); createDefaultCallback( PrePersist.class, PseudoJpaDotNames.DEFAULT_PRE_PERSIST, callbackClassName, callbacksByType ); createDefaultCallback( PreRemove.class, PseudoJpaDotNames.DEFAULT_PRE_REMOVE, callbackClassName, callbacksByType ); createDefaultCallback( PreUpdate.class, PseudoJpaDotNames.DEFAULT_PRE_UPDATE, callbackClassName, callbacksByType ); createDefaultCallback( PostLoad.class, PseudoJpaDotNames.DEFAULT_POST_LOAD, callbackClassName, callbacksByType ); createDefaultCallback( PostPersist.class, PseudoJpaDotNames.DEFAULT_POST_PERSIST, callbackClassName, callbacksByType ); createDefaultCallback( PostRemove.class, PseudoJpaDotNames.DEFAULT_POST_REMOVE, callbackClassName, callbacksByType ); createDefaultCallback( PostUpdate.class, PseudoJpaDotNames.DEFAULT_POST_UPDATE, callbackClassName, callbacksByType ); if ( !callbacksByType.isEmpty() ) { jpaCallbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, true ) ); } }
private void processJpaCallbacks(String instanceCallbackClassName, boolean isListener, List<JpaCallbackClass> callbackClassList) { ClassInfo callbackClassInfo = getLocalBindingContext().getClassInfo( instanceCallbackClassName ); // Process superclass first if available and not excluded if ( JandexHelper.getSingleAnnotation( callbackClassInfo, JPADotNames.EXCLUDE_SUPERCLASS_LISTENERS ) != null ) { DotName superName = callbackClassInfo.superName(); if ( superName != null ) { processJpaCallbacks( instanceCallbackClassName, isListener, callbackClassList ); } } Map<Class<?>, String> callbacksByType = new HashMap<Class<?>, String>(); createCallback( PrePersist.class, JPADotNames.PRE_PERSIST, callbacksByType, callbackClassInfo, isListener ); createCallback( PreRemove.class, JPADotNames.PRE_REMOVE, callbacksByType, callbackClassInfo, isListener ); createCallback( PreUpdate.class, JPADotNames.PRE_UPDATE, callbacksByType, callbackClassInfo, isListener ); createCallback( PostLoad.class, JPADotNames.POST_LOAD, callbacksByType, callbackClassInfo, isListener ); createCallback( PostPersist.class, JPADotNames.POST_PERSIST, callbacksByType, callbackClassInfo, isListener ); createCallback( PostRemove.class, JPADotNames.POST_REMOVE, callbacksByType, callbackClassInfo, isListener ); createCallback( PostUpdate.class, JPADotNames.POST_UPDATE, callbacksByType, callbackClassInfo, isListener ); if ( !callbacksByType.isEmpty() ) { callbackClassList.add( new JpaCallbackClassImpl( instanceCallbackClassName, callbacksByType, isListener ) ); } }
@PostRemove public void postRemoveLifecycleMethod() { postRemoveCount++; if (postRemoveCount != preRemoveCount) { throw new IllegalStateException("postRemoveCount(" + postRemoveCount + ") != preRemoveCount(" + preRemoveCount + ")"); } }
@PostRemove public void postRemove(E entity) { T delegate = getDelegate(); if (delegate != null) { delegate.postRemove(entity); } }
/** * Clear categories and order items from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceCategory.class); CacheManager.MANAGER.clearRemoteCache(PersistenceProduct.class); }
/** * Clear users and order items from cache post remove. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceOrder.class); CacheManager.MANAGER.clearRemoteCache(PersistenceUser.class); }
/** * Clear products from cache to update relationships. */ @PostRemove private void clearCaches() { CacheManager.MANAGER.clearCache(PersistenceProduct.class); CacheManager.MANAGER.clearRemoteCache(PersistenceCategory.class); }
@PostRemove public void postRemove(Object entity) { notifyEntityPushers(EntityAction.REMOVED, entity); }
@PostRemove public void postRemove(Object object) { LOG.info("Listening to post remove for object:" + object); }
@PostRemove private void postRemove(Object object) { logger.debug("### DebugListener.postRemove({})", object); }
@PostRemove void postRemove() { callbacks.add(PostRemove.class); }
@PostRemove @PostPersist @PostUpdate public void onPostModyfingOperation(final Object o) { markWrite(); }
@PostRemove void postDelete(AuditableBaseEntity e) { createLog(DatabaseTransactionType.DELETE, e); }
@PostRemove public void postRemove(TwitterUser entity) { System.out.println("Spring PostRemove, key: " + key); }
public void findMethodsForListener(Object listener) { Class<?> c = listener.getClass(); for (Method m : c.getMethods()) { if (Void.TYPE.equals(m.getReturnType())) { Class<?>[] types = m.getParameterTypes(); if (types.length == 1) { // check for all annotations now... if (m.getAnnotation(PrePersist.class) != null) { if (!preInsert.containsKey(types[0])) { preInsert.put(types[0], new LinkedHashMap<Method, Object>()); } preInsert.get(types[0]).put(m, listener); } if (m.getAnnotation(PostPersist.class) != null) { if (!postInsert.containsKey(types[0])) { postInsert.put(types[0], new LinkedHashMap<Method, Object>()); } postInsert.get(types[0]).put(m, listener); } if (m.getAnnotation(PreUpdate.class) != null) { if (!preUpdate.containsKey(types[0])) { preUpdate.put(types[0], new LinkedHashMap<Method, Object>()); } preUpdate.get(types[0]).put(m, listener); } if (m.getAnnotation(PostUpdate.class) != null) { if (!postUpdate.containsKey(types[0])) { postUpdate.put(types[0], new LinkedHashMap<Method, Object>()); } postUpdate.get(types[0]).put(m, listener); } if (m.getAnnotation(PreRemove.class) != null) { if (!preRemove.containsKey(types[0])) { preRemove.put(types[0], new LinkedHashMap<Method, Object>()); } preRemove.get(types[0]).put(m, listener); } if (m.getAnnotation(PostRemove.class) != null) { if (!postRemove.containsKey(types[0])) { postRemove.put(types[0], new LinkedHashMap<Method, Object>()); } postRemove.get(types[0]).put(m, listener); } if (m.getAnnotation(PostLoad.class) != null) { if (!postLoad.containsKey(types[0])) { postLoad.put(types[0], new LinkedHashMap<Method, Object>()); } postLoad.get(types[0]).put(m, listener); } } } } }
@PostRemove public void postRemove(TwitterUser entity) { System.out.println("JPA PostRemove"); }
@PostRemove public void postRemove(Object obj) { System.out.println("PostRemove: " + obj); }
@PostRemove public void postRemove() { System.out.println("A cat was abandoned: " + this); }
@PostRemove public void loggRemoval() { logger.info("Deleted {}", this); }
@PostRemove public String getExtId() { return extId; }
/** * 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()); }
/** * 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 }
/** * 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)); }