Re: Inheritance Problem
Re: Inheritance Problem
- Subject: Re: Inheritance Problem
- From: Chuck Hill <email@hidden>
- Date: Wed, 17 May 2006 09:57:01 -0700
On May 16, 2006, at 1:23 PM, David Avendasora wrote:
I am using vertical-mapping for my inheritance (I know, not a good
idea, but work with me). I'm using it in another inheritance
relationship in the same model and it works just fine in that one,
but in this one it doesn't, very odd.
That might only be temporary. The way that EOF determines the
operation ordering is opaque and seems to change in response to the
object graph.
My database is MS SQL Server 2000, and it doesn't appear to have
deferrable constraints. Is there a way to force EOF to do its SQL
in a more logical order?
Yes, see the last paragraph in the message below.
I mean really, if one entity is a parent of another, you'd think
EOF would insert that one into the DB first.
That does not mean that is what it does! :-P
If I have to I can switch to single-table mapping, which would
eliminate the constraint problem. I just cringe at having two
different mapping strategies in the same model and I really don't
want to change the other one.
I often use different mapping strategies in the same model.
Chuck
Dave
On May 16, 2006, at 7:46 PM, Chuck Hill wrote:
Hi David,
I am not too clear on our inheritance configuration from your
message. Two possibilities jump to mind.
1. If you have the sub-entities in their own tables, then you
can't enforce foreign-key constraints. i.e. If you have a Person
entity in a Person table and an Employee entity in a Employee
table, then you can't enforce a foreign-key constraint from
Department to Person as the rows will actually be in the Employee
table. The solution to this is to remove the impossible foreign-
key constraints.
2. EOF often performs operations on the database in an order other
than what you might desire. For example, it may insert a row into
the Employee table before inserting the corresponding row into the
Department table (assuming you are creating a new Department and
Employee in the same transaction). There are two solutions to this.
If you are using a real database (e.g. whOracle, FrontBase,
PostgreSQL) then generate the foreign-key constraints with
DEFERRABLE INITIALLY DEFERRED. This will cause the database to
check integrity when the COMMIT is issued instead of checking it
after every statement is executed. With the proper EOModeler
plugin (which is different than the EOF plugin), this SQL should
be generated automatically.
If you are using MySQLToy or something else that does not support
DEFERRABLE INITIALLY DEFERRED, there is a delegate of
EOAdaptorChannel that you can use to order the operations in
code. Project Wonder has an implementation of this. I have never
used it, so have no more information on it.
Chuck
On May 16, 2006, at 8:25 AM, David Avendasora wrote:
Hi all,
I am trying to save an instance of a subclass to the database
after creating it from scratch. I am getting a foreign-key
constraint error from the database because it hasn't created the
database record for the parent class yet, which has a one-to-one
relationship configured in the database.
I've recreated the relationship in the DB and in EOModeler just
to make sure I had done it correctly, but I'm still getting the
same error.
Any ideas? Am I missing something obvious?
Thanks,
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Coming in 2006 - an introduction to web applications using
WebObjects and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve
specific problems. http://www.global-village.net/products/
practical_webobjects
--
Coming in 2006 - an introduction to web applications using WebObjects
and Xcode http://www.global-village.net/wointro
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden