cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: To dep PK
Date Wed, 03 Oct 2007 13:27:42 GMT
Hi Neil, I'll send you an example model off-list since the mailing
list doesn't support attachments.

/dev/mrg


On 10/2/07, pinkybum_nabble <neil.pinkerton@jdsu.com> wrote:
>
> 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.
>
>

Mime
View raw message