details:   /erp/devel/pi/rev/38158faa4a84
changeset: 8010:38158faa4a84
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Tue Aug 03 14:54:55 2010 +0200
summary:   Fixes issue 14119: OBInterceptor sets detached user object from 
OBContext in updatedBy property

diffstat:

 src/org/openbravo/dal/core/OBInterceptor.java |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r c1ecf803c62a -r 38158faa4a84 
src/org/openbravo/dal/core/OBInterceptor.java
--- a/src/org/openbravo/dal/core/OBInterceptor.java     Tue Aug 03 14:52:10 
2010 +0200
+++ b/src/org/openbravo/dal/core/OBInterceptor.java     Tue Aug 03 14:54:55 
2010 +0200
@@ -279,7 +279,7 @@
     // check is done (see onSave). This is before hibernate can copy
     // the changes from currentState to the object. This happens slighlty 
later.
     final OBContext obContext = OBContext.getOBContext();
-    final User currentUser = obContext.getUser();
+    final User currentUser = getCurrentUser();
     log.debug("OBEvent for new object " + traceable.getClass().getName() + " 
user "
         + currentUser.getName());
 
@@ -329,7 +329,7 @@
   // Sets the updated/updatedby
   // TODO: can the client/organization change?
   protected void onUpdate(Traceable t, String[] propertyNames, Object[] 
currentState) {
-    final User currentUser = OBContext.getOBContext().getUser();
+    final User currentUser = getCurrentUser();
     log.debug("OBEvent for updated object " + t.getClass().getName() + " user "
         + currentUser.getName());
     for (int i = 0; i < propertyNames.length; i++) {
@@ -351,4 +351,10 @@
     }
   }
 
+  // reads the current user from the database, note multiple reads
+  // will hit the session cache
+  private User getCurrentUser() {
+    return SessionHandler.getInstance()
+        .find(User.class, OBContext.getOBContext().getUser().getId());
+  }
 }
\ No newline at end of file

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to