Re: Object in DB Error after using addObjectToBothSidesOfRelationshipWithKey

Markus Ruggiero <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Hi,
after a short look at your code I see that you violate one of the EO  
principles: Never ever modify an EO that has not been inserted into  
the editing context

[...SNIP...]

>     public My_Rep_CurrentReading addSummary()
>     {
> My_Rep_CurrentReading nextPage =
>         (My_Rep_CurrentReading)pageWithName("My_Rep_CurrentReading");
>
>         // Initialize your component here
> 		EOEditingContext ec = session().defaultEditingContext();
> 		NSTimestamp currentTime = new NSTimestamp();
> 			
> 		
Here aSummary is modified  ....

> 			aSummary.setEntryDate(currentTime);
> 		
... and only now you insert it into an ec.   WRONG SEQUENCE of action!!
> 			ec.insertObject( aSummary );
> 			
>
[...SNIP...]

This may work or may not. In your case it seems not to.
> 			ec.saveChanges();
>
Or it may be something completely different that I have not realised  
but anyway correct the sequence of action first
Have fun
---markus---

Markus Ruggiero
rucotec consulting and technologies    email      
mailto:[email protected]
rucotec GmbH                           web       http://www.rucotec.ch
Steinentorstrasse 8
4051 Basel                             Mobile    +41 (0)79 508 4701
Switzerland                            Phone/Fax +41 (0)61 271 4990

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.