Ticket Q408356
Visible to All Users

Object is marked modified although NonPersistentChangesEnabled is set to false

created 13 years ago

Hi,
please have a look at the attached example and do the following steps:

  1. start the application
  2. navigate to "Bo Without Non Persistent Property"
  3. execute the NewAction for this bo type
  4. within the DetailView enter a name and execute "SaveAndClose" Action
  5. execute the NewAction for this bo type again
  6. within the DetailView enter a name and execute "SaveAndClose" Action
  7. "Error: The object you are trying to save was changed by another user … BoWithNonPersistentProperty …"
    There is a controller which modifies only nonpersistent properties in this solution. But it seems that this modification is the reason for the exception. But this exception shouldn't be raised because I set the NonPersistentChangesEnabled Property to false. (like described here)
    Thanks, Matthias

Answers

created 13 years ago (modified 12 years ago)

Hello Kim,
I am afraid that the "object you are trying to save was changed by another user" exception cannot be avoided via the NonPersistentChangesEnabled property. When you are changing a property in whose setter the SetPropertyValue method is used, the Changed notification is raised. This notification is handled both by XPO and XAF. When it is handled by XAF, we check the NonPersistentChangesEnabled property and do not change the ObjectSpace's modified state. However, the object is still added to the list of modified objects, because XPO does not take the NonPersistentChangesEnabled property into account. When an object is added to a list of the modified objects in several views, the mentioned error occurs. To solve the problem, either modify the object in the same ObjectSpace, or do not use the SetPropertyValue method in the non-persistent property setter (i.e. simply use the variable = value assignment).

    Show previous comments (2)

      Hello Anatol,
      thank you for your feedback. Because of the XPO level problems we reset the NonPersistentChangesEnabled option to default again. Is there any possibility to get this feature working with XPO? Isn't the option rather useless at the moment? If you say you don't have plans to implement something regarding this topic, do you have any recommendations? Maybe we can implement a fix ourselves?
      Thank you
      Christian

      Anatol (DevExpress) 12 years ago

        Currently the default value of the NonPersistentChangesEnabled property is false. This property works as we expected, and we believe that there is no need to change its behavior. As for recommendations, I suggest that you follow the previously provided ones - modify objects in the same ObjectSpace or reload an object modified in another ObjectSpace. If there are issues with implementing this, please describe your scenario in greater detail.

        Dennis Garavsky (DevExpress) 12 years ago

          @Christian: Please check out the Session - Provide the capability to not mark a persistent object as modified for saving if only its non-persistent properties were changed ticket for a possible solution available in the next XPO version.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.