On Feb 3, 2007, at 1:36 PM, Steven Mark McCraw wrote:

I recall reading in some of the early Apple WebObjects documentation that it's a huge terrible thing to mark your foreign and primary keys as class properties (e.g. check the little diamond in EOModeler so that your generated classes give you setters and getters to access them directly).

A problem with doing this would be that setting a primary key will raise an exception because EOF doesn't allow primary keys to be updated. Setting a foreign key directly will likely confuse EOF because the object graph will then be inconsistent. So setters for primary and foreign keys should not be used but will be available to be used unless you manually remove them from the class implementation and remember to do so whenever you regenerate class implementations using EOModeler or eogenerator.

Over the years, I've often thought it would be convenient to have the keys as class properties, particularly when I've had to write custom queries. I know EOUtilities gives you methods to get the primary and foreign keys for an object, but using these are kind of a pain compared to just calling a simple accessor method.

Why not just define getter methods in the class implementation for the primary and foreign keys that you really need to access via Java? You can implement them using the EOUtilities methods. Doing so would avoid the potential problems caused by setting them to be class properties.

Aloha,
Art

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to