Re: EOF inserts PK automatically
Re: EOF inserts PK automatically
- Subject: Re: EOF inserts PK automatically
- From: Marek Wawrzyczny <email@hidden>
- Date: Thu, 18 Nov 2004 09:37:15 +1100
On 11/11/2004, at 04:39, Ruenagel, Frank wrote:
Actually as far as I can tell, the EO_PK_TABLE is not the table that
WebObjects uses to get the next PK. It's easy to test this. On a
development (not your production) database, start up your
application,
create some records in a table of your choice (either through another
application or through the database) and don't update the
EO_PK_TABLE.
EOF will still generate records with the correct PK. In fact you can
drop the entire EO_PK_TABLE table altogether and WebObjects will
still
happily create it and keep on working.
I am not sure what EOF needs EO_PK_TABLE for, but it does not seem to
need it for the generation of PKs. I remember reading on Omnigroup
that
EOF always gets the max() value on the PK column prior to generating
the PK. You are always guaranteed to get a unique PK for your
records.
Wrong. Make a test.
Well, it is quarter true. ;-)
If EOF uses the standard-mechanism of PK-Generation as it is
implemented
in the jdbc-adaptor:
EOF uses EO_PK_Table if it exists. If EO_PK_Table is not there,
it will be rebuild on demand. And "demand" means: insert a new row.
If the table-name of a table in which a new pk should be inserted is
not
listed in the EO_PK_TABLE-table, the correspondig row in EO_PK_TABLE
will be
created.
In this case EOF uses a max(pk)-query.
This means: EOF works fine without EO_PK_Table. Deleting lines in the
table
or
dropping the whole table does not affect functionality.
I have tested this with the ms-sql-adaptor, which uses the default
implementation
of pk-generation.
I know this is late, but hopefully this will help Sako. Yeah, I should
have tested that. Mind you, seems like no one here is quite right.
According to the Apple docs (why didn't I Google to begin with?), WO
uses different PK generation mechanisms for different databases. For
example, the EO_PK_TABLE is not used at all with Oracle. It also
provides hooks for generating PKs. For an overview goto:
http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/
Saving/chapter_8_section_5.html
PK generation example is found here:
http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/
Saving/chapter_8_section_7.html#//apple_ref/doc/uid/TP30001011-
DontLinkChapterID_14-TPXREF153
And even compound PKs can be implemented:
http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/
Saving/chapter_8_section_8.html#//apple_ref/doc/uid/TP30001011-
DontLinkChapterID_14-BADJEBIB
So nothing appears impossible.
Marek Wawrzyczny
software engineer
-------------------------->
ish group pty ltd
http://www.ish.com.au
7 Darghan St Glebe 2037 Australia
phone +61 2 9660 1400 fax +61 2 9660 7400
_______________________________________________
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