Thanks for reply. I tried several things, so i copied maybe the wrong version. But i will Check it.
Am Dienstag, 10. Dezember 2013 schrieb Mike Kienenberger : > You can have id in a join table, but did you mark it as a primary key? > > > I see > > <db-attribute name="id" type="INTEGER" isMandatory="true" > length="10"/> > > But shouldn't it be > > > <db-attribute name="id" isPrimaryKey="true" type="INTEGER" > isMandatory="true" > length="10"/> > > On Tue, Dec 10, 2013 at 4:53 AM, jotpe <[email protected] <javascript:;>> > wrote: > > Hello list, > > > > I'm getting started with cayenne 3.2M1. Until now serveral things are > > working fine, like expected. > > > > My user object has a list of roleGroups. If i add a roleGroup to its list > > and call commitChanges() and SQL Exception is thrown: > > org.postgresql.util.PSQLException: FEHLER: NULL-Wert in Spalte »id« > > verletzt Not-Null-Constraint > > > > Generally calling the sequence for next id, is no problem, look the > > statments for inserting a new user: > > > > Information: SELECT nextval('user_id_seq') > > Information: INSERT INTO "public"."user" ("changepasswort", > > "displayname", "id", "lastchanged", "loginname", "password", "validfrom", > > "validuntil") VALUES (?, ?, ?, ?, ?, ?, ?, ?) > > Information: [batch bind: 1->changepasswort:NULL, 2->displayname:'xy', > > 3->id:9, 4->lastchanged:'2013-12-10 10:41:03.812', 5->loginname:'xyz', > > 6->password:'geheim', 7->validfrom:NULL, 8->validuntil:NULL] > > > > But no sequence is called when commiting the new relationship. > > > > Information: SELECT "t0"."changepasswort", "t0"."displayname", > > "t0"."lastchanged", "t0"."loginname", "t0"."password", "t0"."validfrom", > > "t0"."validuntil", "t0"."id" FROM "public"."user" "t0" WHERE "t0"."id" = > ? > > [bind: 1->id:1] - prepared in 94 ms. > > Information: SELECT DISTINCT "t0"."description", "t0"."lastchanged", > > "t0"."name", "t0"."id" FROM "public"."rolegroup" "t0" JOIN > > "public"."joinuserrolegroup" "t1" ON ("t0"."id" = "t1"."rolegroupid") > WHERE > > "t1"."userid" = ? [bind: 1->userid:1] - prepared in 15 ms. > > Information: SELECT "t0"."description", "t0"."lastchanged", > "t0"."name", > > "t0"."id" FROM "public"."rolegroup" "t0" WHERE "t0"."id" = ? [bind: > 1->id:3] > > Information: INSERT INTO "public"."joinuserrolegroup" ("id", > > "rolegroupid", "userid") VALUES (?, ?, ?) > > Information: [batch bind: 1->id:NULL, 2->rolegroupid:3, 3->userid:1] > > Information: *** error. > > org.postgresql.util.PSQLException: FEHLER: NULL-Wert in Spalte »id« > > verletzt Not-Null-Constraint > > > > Is this default-behaviour? Is no id column in jointables intended? > > > > The db-entity from my datamap.map.xml > > <db-entity name="joinuserrolegroup" schema="public"> > > <db-attribute name="id" type="INTEGER" isMandatory="true" > > length="10"/> > > <db-attribute name="rolegroupid" type="INTEGER" length="10"/> > > <db-attribute name="userid" type="INTEGER" length="10"/> > > <db-key-generator> > > <db-generator-type>ORACLE</db-generator-type> > > > <db-generator-name>joinuserrolegroup_id_seq</db-generator-name> > > </db-key-generator> > > </db-entity> > > > > As you can see, i'm using a postgres database 9.1 > > Here are the three table definitions: > > > > > > > > Table "public.user" > > Column | Type | > > Modifiers > > > ----------------+-----------------------------+--------------------------------------------------- > > id | integer | not null default > > nextval('user_id_seq'::regclass) > > loginname | character varying(100) | > > displayname | character varying(100) | > > password | character varying(100) | > > validfrom | timestamp without time zone | > > validuntil | timestamp without time zone | > > lastchanged | timestamp without time zone | > > changepasswort | boolean | > > Indexes: > > "user_pkey" PRIMARY KEY, btree (id) > > > > > > Table "public.rolegroup" > > Column | Type | > Modifiers > > > -------------+-----------------------------+-------------------------------------------------------- > > id | integer | not null default > > nextval('rolegroup_id_seq'::regclass) > > name | character varying(100) | > > description | character varying(100) | > > lastchanged | timestamp without time zone | > > Indexes: > > "rolegroup_pkey" PRIMARY KEY, btree (id) > > > > > > AND FINALLY THE JOINTABLE > > > > Table "public.joinuserrolegroup" > > Column | Type | Modifiers > > > -------------+---------+---------------------------------------------------------------- > > id | integer | not null default > > nextval('joinuserrolegroup_id_seq'::regclass) > > userid | integer | > > rolegroupid | integer | > > Indexes: > > "joinuserrolegroup_pkey" PRIMARY KEY, btree (id) > > > > > > Best regards, Johannes >
