On Thursday, June 5, 2003, at 12:14 PM, Adrian wrote:
> I use the modeler in order to generate my object's
> classes...but I had to manualy add every attribute
> that is associated with a PK field.
> This PK have conains meaningful data under my
> application context....
During reverse engineering the database, Cayenne assumes that all PK
columns are not meaningful, and therefore does not create ObjAttributes
for them. Like you noticed, it is easy to fix manually.
> My question is...are there any way to indicate to
> Cayenne modeler that i will provide this values and
> they will not be autogenerated?....
Cayenne tries all options (using object value, pulling value from
"master" object) before resorting to autogeneration (also see below).
>
> I put all this PK attributes by hand and also create
> the classes without problems...but when I commited
> changes (A new and registered object with all field
> properly loaded i got this message:
>
> org.objectstyle.cayenne.CayenneRuntimeException:
> [v.1.0b3 May 25 2003]
> org.objectstyle.cayenne.CayenneException: [v.1.0b3 May
> 25 2003] Null master object, can't create primary key.
> at
> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.ja
> va:735)
> at
> org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.ja
> va:706)
Looks like your mapping forces Cayenne to exercise "pulling value from
'master' object" option. Primary key value in question seems to be a
target of a relationship from a "master" entity to dependent one ("to
dep pk" is checked), but the "master" object is not set, hence the
exception "Null master object".
Either revisit your mapping, or make sure that the object that is the
source of primary key value for the given object, is set before
DataContext is committed. On Cayenne side I guess we should provide a
more verbose exception. I will work on that.
Andrus
This archive was generated by hypermail 2.0.0 : Fri Jun 06 2003 - 01:26:55 EDT