Hi Martin,
It looks like it is the "To Dep PK" problem to me. I'm sure you can find
some hints from the replies to the thread -
"To Dep PK? Michael Schuldt (Wed Jan 15 2003 - 03:48:55 EST) ".
You could look at the setting for the db-relationship entries between the
project table & rates table, employee table & rates table in the data map
xml file.
By modifying one of the replies from Andrus to the "1:n deletion problem"
thread, the following could be useful in your case,
----------------------------------------------------------------------------
-
DbRelationships *to* rates must be marked as "To Dep PK". Those include:
- project.ratesArray
- employee.ratesArray
----------------------------------------------------------------------------
-
You can set these up in the Moduler too.
Hope this helps.
Bill
----- Original Message -----
From: "martin ruff" <mruf..imeon.ch>
To: <cayenne-use..bjectstyle.org>
Sent: Saturday, January 18, 2003 7:07 PM
Subject: Auto PK generation problem
> Hi,
> All (but one) my tables have a technical autogenerated primary key, this
> works very well with cayenne.
> now I have 1 table with a composite PK:
> CREATE TABLE rates(
> projectid int4 NOT NULL,
> employeeid int4 NOT NULL,
> rate numeric NOT NULL,
> FOREIGN KEY (projectid) REFERENCES projects (id),
> FOREIGN KEY (employeeid) REFERENCES employees (id),
> PRIMARY KEY (projectid,employeeid));
>
> now when i try to insert a new Rates object:
> (I've defined the relations toemployee and toproject in cayenne modeler)
> Employees theemployee =
> EmployeeService.findEmployeeByID(theDataContext, employeesID);
> Projects theproject =
> ProjectsService.findProjectsByID(theDataContext, projectsID);
>
> Rates theRate2Insert = new Rates();
> theDataContext.registerNewObject(theRate2Insert);
> theRate2Insert.setToEmployees(theemployee);
> theRate2Insert.setToProject(theproject);
> theRate2Insert.setRate(amount);
> theDataContext.commitChanges(Level.WARN);
>
> I get a:CayenneRuntimeException
> Primary Key autogeneration only works for a single attribute.
>
> but I've set the primary keys by setting the relations, which are the PK,
> can I tell cayenne, to not try to generate a PK?
> thanks for help
> martin
>
>
>
This archive was generated by hypermail 2.0.0 : Sat Jan 18 2003 - 04:42:04 EST