Hi Andrew,

You don't show the relevant stack, so I can only guess. But I find the 
following code suspect:

>    project.setObjectContext(oc);
>    project.getCompany().setObjectContext(oc);

Setting ObjectContext explicitly on Persistent objects is never a good idea. 
Object should stay in the ObjectContext it was created in or fetched from). Any 
specific reason why you are doing that?

Andrus 



> On Mar 3, 2016, at 6:15 AM, Andrew Willerding <awillerd...@itsurcom.com> 
> wrote:
> 
> I am stuck on exactly what this message means and how to correct the 
> situation.
> 
> Here are my table relationships.
> 
> Project               ProjectContact         Contact
> ---------               --------------------         ----------
> ProjectID <--->     ProjectID
>                              ContactID    <--->  ContactID
> 
> Here is my code.
> 
>                ObjectContext oc = UI.getObjectContext();
>                for (Contact item : list) {
>                    ProjectContact newItem = 
> oc.newObject(ProjectContact.class);
>                    project.setObjectContext(oc);
>                    project.getCompany().setObjectContext(oc);
>                    newItem.setCompany(project.getCompany());
>                    item.setObjectContext(oc);
> exception->newItem.setContact(item);
>                    newItem.setProject(project);
> newItem.setPrimeContact(ProjectContact.Type.NON_PRIME.getCode());
>                    addItemCount++;
> 
> Here's the exception that is thrown when the newItem.setContact(item) is 
> executed.
> 
> 2016-03-02,22:00:25:587,ERROR,[Thread-83],,'com.callistacti.vaadinLib.IWindowEditBase'
>  ERROR:ObservableComponent Error processing observer's update code. 
> Observer==>class 
> com.itsurcom.bluecranex.GUI.Panels.PanelProjectContacts::org.apache.cayenne.CayenneRuntimeException:
>  [v.4.0.M3 Feb 08 2016 17:09:41] No object is registered in context with Id 
> <ObjectId:Contact, ContactID=1170>
> 

Reply via email to