Search   

Sunday, February 05, 2012

Support » Support Forum

Register  Login

 Menu  
 
    

 Welcome!  
 


Welcome to the NDO support forum!

kreis.gif Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender.
kreis.gif Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts.
kreis.gif The forum software requires that javascript is enabled.
kreis.gif Please do not insert licence information or licence keys in forum posts.
kreis.gif If you know a good answer to a post of another user, feel free to reply!
kreis.gif The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.

   Print   

      
 NDO Support Forum  
 
SearchForum Home
  NDO-Forum postings in english please, if possible.  Developing with NDO  Can't update pe...
 Can't update persistent object
 
 7/16/2006 11:17:31 PM
Marc
8 posts


Can't update persistent object
 Modified By Mirko  on 7/18/2006 10:17:12 AM)

Hi!

I use this code to update a persistent object:

PersistenceManager pm = new PersistenceManager();
pm.MakePersistent(odlSalutationLetter);
pm.Save();

After pm.Save() I get this exception:

MakePersistent: Object is already persistent: [Type = ...|Id = ...]"
Source="NDO"
...

I use NDO Professional version 1.2.0.0.

What have I done wrong?

Best Regards,

Marc Haid

 7/17/2006 10:55:04 AM
Mirko
109 posts
5th


Re: Can't update persistent object
 Modified By Mirko  on 7/17/2006 10:55:27 AM)

Hi Marc,

updating an object simply requires calling Save().

MakePersistent is only used to store an object in the first place, thus making it persistent.

If you change a persistent object, the object marks itself as Dirty and NDO updates the data row during the next call to Save().

I hope, that helps!

Best Regards:
Mirko

 7/17/2006 10:38:13 PM
Marc
8 posts


Re: Can't update persistent object
 Modified By Marc  on 7/17/2006 10:39:13 PM)
Hi!

I changed the code, so that MakePersistent only is called when the object has the NDOObjectState = Transistent.

If I update only the Save() method is called, but the value I changed isn't updated at the database.

Must I do something else?

Best Regards,

Marc Haid
 7/18/2006 10:15:33 AM
Mirko
109 posts
5th


Re: Can't update persistent object

Hi Marc,

creating and changing an object are two different scenarios.

1. Creating:

Employee e = new Employee();
// Setting the properties occurs
// the UI
e.FirstName = "Mirko";
e.LastName = "Matytschak";
pm.MakePersistent(e);
pm.Save();

2. Changing

// e might be retrieved by a query
// Setting the properties normally
// occurs in the UI
e.FirstName = "Johnny";
e.LastName = "Winter";
pm.Save();
// new state of e is in the database

Have a look at our Tutorial application to see, how these things work.

Best Regards
Mirko

 7/18/2006 11:36:34 AM
Marc
8 posts


Re: Can't update persistent object
Hi Mirko,

here is my code snippet for creating and changing respectively:

public void Save()
{
// Es wurde keine Briefanrede eingegeben
if (odlSalutationLetter.SalutationLetter != "" && odlSalutationLetter.SalutationLetter != null)
{
PersistenceManager pm = new PersistenceManager();
if (ObjectHelper.GetObjectId(odlSalutationLetter) == null)
{
pm.MakePersistent(odlSalutationLetter);
}
pm.Save();
}
}

I think it should combine the two possibilities.

I think the problem might be the data binding. I generate a NDOArrayList of objects, bind it to an GridView and I use "sender.DataSource(e.NewEditIndex)" to get the selected object from the Grid and put it to my BusinessLogic ("oblSalutatuionLetter.getObject(sender.DataSource(e.NewEditIndex))").

The GUI is an ASP.NET site and the Grid is placed at an user control.

Is that a possibility for the problem?

Best Regrads,

Marc Haid
  NDO-Forum postings in english please, if possible.  Developing with NDO  Can't update pe...
  SearchSearch  Forum HomeForum Home