Dave,

a couple things concern me here.

1. having JPA complain about using an object after it is removed seems a bit ridiculous. There are very valid reasons to do this, such as the example below. If you really can't work around this then we should plan to change the various removeXXX() methods to return a safe copy of the deleted object that can continue to be used.

2. moving the invalidation call before the removal is technically incorrect because then if there is an error during the removal you've mistakenly invalidated the template. while this isn't a huge problem in this particular situation it's still not a proper solution and i am guessing that there is somewhere else in the code where doing the same thing could cause more problems.

-- Allen


[EMAIL PROTECTED] wrote:
Author: snoopdave
Date: Fri Jul 20 14:59:06 2007
New Revision: 558166

URL: http://svn.apache.org/viewvc?view=rev&rev=558166
Log:
Fixes ROL-1483 by moving the invalidate cache call before the delete template 
call. Apparently, with JPA, you don't want to attempt to use an object after 
you have deleted it.

Modified:
    
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.java

Modified: 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.java
URL: 
http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.java?view=diff&rev=558166&r1=558165&r2=558166
==============================================================================
--- 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.java
 (original)
+++ 
roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/TemplateRemove.java
 Fri Jul 20 14:59:06 2007
@@ -84,12 +84,13 @@
         if(getTemplate() != null) try {
             if(!getTemplate().isRequired()) {
                 UserManager umgr = 
WebloggerFactory.getWeblogger().getUserManager();
-                umgr.removePage(getTemplate());
-                WebloggerFactory.getWeblogger().flush();
- +
                 // notify cache
                 CacheManager.invalidate(getTemplate());
- +
+                umgr.removePage(getTemplate());
+                WebloggerFactory.getWeblogger().flush();
+ return SUCCESS;
             } else {
                 // TODO: i18n


Reply via email to