You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Radu B (JIRA)" <ji...@apache.org> on 2010/08/27 00:10:55 UTC
[jira] Created: (OPENJPA-1775) Get original object state for audit
purpose
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.
Re: [jira] Created: (OPENJPA-1775) Get original object state for
audit purpose
Posted by Kevin Sutter <kw...@gmail.com>.
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) <ji...@apache.org> 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.
>
>
Re: [jira] Closed: (OPENJPA-1775) Get original object state for
audit purpose
Posted by Pinaki Poddar <pp...@apache.org>.
Kevin is right.
This URL[1] may help to answer your question. (Hint: please be patient to
read to the end :)
[1]
http://webspherepersistence.blogspot.com/2009/01/auditing-with-openjpa.html
-----
Pinaki
--
View this message in context: http://openjpa.208410.n2.nabble.com/jira-Created-OPENJPA-1775-Get-original-object-state-for-audit-purpose-tp5467479p5469828.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.
[jira] Closed: (OPENJPA-1775) Get original object state for audit
purpose
Posted by "Radu B (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/OPENJPA-1775?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Radu B closed OPENJPA-1775.
---------------------------
Resolution: Not A Problem
Question posted on OpenJPA user and dev forum
> 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.