From dev-return-17239-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Thu Aug 26 22:31:00 2010 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 8173 invoked from network); 26 Aug 2010 22:31:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Aug 2010 22:31:00 -0000 Received: (qmail 35348 invoked by uid 500); 26 Aug 2010 22:31:00 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 35254 invoked by uid 500); 26 Aug 2010 22:30:59 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 35246 invoked by uid 99); 26 Aug 2010 22:30:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 22:30:59 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kwsutter@gmail.com designates 209.85.214.46 as permitted sender) Received: from [209.85.214.46] (HELO mail-bw0-f46.google.com) (209.85.214.46) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Aug 2010 22:30:54 +0000 Received: by bwz11 with SMTP id 11so1774810bwz.33 for ; Thu, 26 Aug 2010 15:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=oHd0E7+HDQyjo5pMurl/roSG06JkBWIXbv59uvbR89c=; b=AI84KDeLsS8ej/aX+XD3etsWsyPDwP3OTTo6hcVto+nvbBMg9yaJdKB6sqaXoaVkLy Wq8spEIvtIVjdwwiGU6fblG5KWWVOkKqlf8nFqLqy7O6oCOSKmhU3orla1rF76AgoB/j Y3zapjyjc79zjEOGVOR6WBy6Hzoibk3WjdInI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=WU+kcUufYXudgwsGCk3gTKg5KWq+EGc9VbHe80D+++EdJ/7LS2m4xFZivOM2omPRos XGlQpG+XDQZ1/P1HNpcdjsHe2A92hiKQGei6v4nudQ6ZXIezIdxw1/LX4loJMGTXCK1n oGyzf29cRGkqFcsDg0ux9dv5AmOfl0FTyiKq8= Received: by 10.204.82.6 with SMTP id z6mr6987275bkk.31.1282861832207; Thu, 26 Aug 2010 15:30:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.163.130 with HTTP; Thu, 26 Aug 2010 15:30:12 -0700 (PDT) In-Reply-To: <7969603.18481282860655087.JavaMail.jira@thor> References: <7969603.18481282860655087.JavaMail.jira@thor> From: Kevin Sutter Date: Thu, 26 Aug 2010 17:30:12 -0500 Message-ID: Subject: Re: [jira] Created: (OPENJPA-1775) Get original object state for audit purpose To: dev@openjpa.apache.org Cc: radu@intelliplus.ro Content-Type: multipart/alternative; boundary=0016e6d975c7cdfe4a048ec18b5c --0016e6d975c7cdfe4a048ec18b5c Content-Type: text/plain; charset=ISO-8859-1 You should probably post questions like this to the OpenJPA users or dev forums [1] instead of creating JIRAs. Thanks. Kevin [1] http://openjpa.apache.org/mailing-lists.html On Thu, Aug 26, 2010 at 5:10 PM, Radu B (JIRA) wrote: > Get original object state for audit purpose > ------------------------------------------- > > Key: OPENJPA-1775 > URL: https://issues.apache.org/jira/browse/OPENJPA-1775 > Project: OpenJPA > Issue Type: Question > Components: Enhance, kernel > Affects Versions: 2.0.0 > Environment: GlassFish 3, OpenJpa 2.0 > Reporter: Radu B > > > I need to get original object state before a merge() is called. > > I tried in my service edit() method, by using : > > public void edit(Customer customer) { > Customer initialState = null; > log.info("About to update customer id " + customer.getCustomerId() > + " with name " + customer.getName()); > > PersistenceCapable currentState = (PersistenceCapable)customer; > > try { > StateManagerImpl sm = > (StateManagerImpl)currentState.pcGetStateManager(); > > SaveFieldManager sfm = sm.getSaveFieldManager(); > PersistenceCapable oldState = sfm.getState(); > > initialState = (Customer)oldState; > > log.info("Customer id " + customer.getCustomerId() + " OLD NAME > WAS " + initialState.getName()); > } > catch (Exception e) { > log.severe("Failed to get old object state: " + e.toString()); > } > > getEntityManager().merge(customer); > } > > > I get the error: > > SEVERE: Failed to get old object state: java.lang.ClassCastException: > org.apache.openjpa.kernel.DetachedStateManager cannot be cast to > org.apache.openjpa.kernel.StateManagerImpl > > Can you please suggest a way to get the original loaded object? > > > -- > This message is automatically generated by JIRA. > - > You can reply to this email to add a comment to the issue online. > > --0016e6d975c7cdfe4a048ec18b5c--