To dep PK

From: pinkybum_nabble (neil.pinkerto..dsu.com)
Date: Tue Oct 02 2007 - 17:32:43 EDT

  • Next message: Aristedes Maniatis: "Re: To dep PK"

    I have only been looking into this tool for a couple of days now and I am
    finding it great to work with and easy to use. However, I have been having
    an issue which may be my ignorance of database relationships. I have defined
    dbEntities and relationships much like:

    MasterEntity
    DependentEntity

    The relationship is One-to-many (one Master to Many Dependents)

    I have created the analogous object entities. When I manipulate these
    objects in java using code like:

                    Master mas = null;
                    Dependent dep1 = null;
                    Dependent dep2 = null;
                    mas = (Master)context.newObject( Master.class );
                    mas.setNumber( Integer.valueOf( 100 ));
                    dep1 = (Dependents)context.newObject( Dependents.class );
                    dep1.setName( "DependentNumber A");
                    mas.addToDependents( dep1 );
                    dep2 = (Dependents)context.newObject( Dependents.class );
                    dep2.setName( "DependentNumber B");
                    mas.addToDependents( dep2 );
                    
                    context.commitChanges();
                    
    I get an exception which indicates that the database tried to create a
    Dependent entry with a duplicate primary key. The only configuration which
    alleviates this problem and creates unique Dependent keys is checking the
    "To dep PK" checkbox on the dependent side of the relationship. Reading the
    documentation it seems to suggest that the checkbox should be checked on the
    master side of the relationship. Did I just read wrongly, can't I just leave
    the checkbox blank or is there some other configuration I am missing when I
    create my schemas? I would like to get this issue resolved before adding
    full database support to the project via Cayenne and deploying the
    production database.

    Many Thankls
    Neil Pinkerton

    -- 
    View this message in context: http://www.nabble.com/To-dep-PK-tf4558289.html#a13008451
    Sent from the Cayenne - User mailing list archive at Nabble.com.
    



    This archive was generated by hypermail 2.0.0 : Tue Oct 02 2007 - 17:33:16 EDT