Re: Help to insert foreign key!

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Aug 12 2004 - 12:08:32 EDT

  • Next message: ROB ROBINSON: "Subject: Issue with Reverse Engineering Sybase Database"

    Reinaldo Coelho Sartorelli <reinaldo_sartorell..ahoo.com.br> wrote:
    > *****************************************
    > And i insert a register using a method gravarBanda(DataContext con, Bandas

    > banda) to register a class, but generate this exception :
    >
    > ***
    > Error : org.objectstyle.cayenne.CayenneRuntimeException: [v.1.1M7_1 June
    15
    > 2004] Cannot set object as destination of relationship toGeneros because
    it
    > is in a different DataContext
    > ***
    >
    > This a code for insert a register :
    >
    >
    > *****************************************
    > Bandas b = new Bandas();
    > b.setToGeneros(ge); //Set a relational Genero from Bandas

    Hi Reinaldo,

    b must be in the context of ge before you can set a relationship to them.

    Simply register it first.

    Or (if it's in another context, which doesn't appear to be the case here),
    use the DataContext.localObjects method.

    See this URL for more information;

    http://www.objectstyle.org/cayenne/userguide/datactxt/moving-objects.html



    This archive was generated by hypermail 2.0.0 : Thu Aug 12 2004 - 12:07:01 EDT