cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emanuele Maiarelli <>
Subject Re: Different DataContext
Date Wed, 22 Jul 2009 10:55:35 GMT
Hi Reinout,

 i'm not an apache Wicket expert, but the Exception its obiusvly casted by the fact that ur
application is casting objects into different DataContexts.
 What happen if u steps into
          final Person auxiliary = ObjectFactory.getInstance().createPerson();

Da: Reinout van Schouwen <>
Inviato: Mercoledì 22 luglio 2009, 12:34:09
Oggetto: Different DataContext

Hi all,

I hope someone can help me with the following issue. I'm using Cayenne
with Databinder and Wicket for my application. In my model, multiple
'PersName' objects can be associated to one 'Person'. But whenever I
try to associate a newly created PersName with a Person, I get a

org.apache.cayenne.CayenneRuntimeException: [v.2.0.4 October 12 2007]
Cannot set object as destination of relationship person because it is
in a different DataContext
     at org.apache.cayenne.CayenneDataObject.willConnect(
     at org.apache.cayenne.CayenneDataObject.setToOneTarget(
     at nl.huygensinstituut.bia.PersonInfoPanel$2.onSubmit(
     at org.apache.wicket.markup.html.form.Form.delegateSubmit(
     at org.apache.wicket.markup.html.form.Form.onFormSubmitted(
     at java.lang.reflect.Method.invoke(
     at org.apache.wicket.RequestListenerInterface.invoke(
     at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(
     at org.apache.wicket.RequestCycle.processEventsAndRespond(
     at org.apache.wicket.RequestCycle.step(
     at org.apache.wicket.RequestCycle.steps(
     at org.apache.wicket.RequestCycle.request(
     at org.apache.wicket.protocol.http.WicketFilter.doGet(
     at org.apache.wicket.protocol.http.WicketFilter.doFilter(
(jetty frames snipped)

Here's a snippet of the failing code:

    DataContext mycontext = Databinder.getContext();
    person = ObjectFactory.getInstance().getPerson(parameters.getInt("personid"),
// ObjectFactory is a singleton. getPerson method executes
DataObjectUtils.objectForPK(context, Person.class, id);

    final PersName nameObj = (PersName) persNameForm.getModelObject();
// PersName extends CayenneDataObject
    persNameForm.add(new Button("submitpersname", new ResourceModel("Save")) {
      public void onSubmit() {

        if (nameObj.getPerson() == null && person == null) {
          final Person auxiliary = ObjectFactory.getInstance().createPerson();
        } else {
          nameObj.setPerson(person); // <-- line 102 where the
exception is triggered. 'person'

Thanks for any advice!

Reinout van Schouwen

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message