You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "John Huss (JIRA)" <ji...@apache.org> on 2013/06/04 23:27:20 UTC

[jira] [Closed] (CAY-1832) Exception when modifying objects in postLoad callback

     [ https://issues.apache.org/jira/browse/CAY-1832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Huss closed CAY-1832.
--------------------------

    Resolution: Fixed
    
> Exception when modifying objects in postLoad callback
> -----------------------------------------------------
>
>                 Key: CAY-1832
>                 URL: https://issues.apache.org/jira/browse/CAY-1832
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.2M1
>            Reporter: John Huss
>            Assignee: John Huss
>            Priority: Minor
>             Fix For: 3.2M1
>
>
> Say you have a postLoad callback on an entity that calls a setter on the object, for example:
> public void publicCallback(Object entity) {
>         Artist a = (Artist)entity;
>         a.setArtistName("Changed");
> }
> This works if you fetch the object directly with a SelectQuery.  But if you fault in the object through a relationship it will call BaseContext.prepareForAccess which has this:
>             // sanity check...
>             if (object.getPersistenceState() != PersistenceState.COMMITTED) {
>                 String state = PersistenceState.persistenceStateName(object
>                         .getPersistenceState());
>                 // TODO: andrus 4/13/2006, modified and deleted states are possible due to
>                 // a race condition, should we handle them here?
>                 throw new FaultFailureException(...
>             }
> Since the object is modified (not committed) an exception is thrown.  It is valid to allow mutating an object during postLoad.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira