RE: EOF inserts PK automatically
RE: EOF inserts PK automatically
- Subject: RE: EOF inserts PK automatically
- From: "Ruenagel, Frank" <email@hidden>
- Date: Wed, 10 Nov 2004 18:39:13 +0100
> -----Original Message-----
> From: Sako! [mailto:email@hidden]
> Sent: Monday, November 08, 2004 1:05 PM
> To: Marek Wawrzyczny
> Cc: email@hidden
> Subject: Re: EOF inserts PK automatically
>
>
>
> ----- Original Message -----
> From: "Marek Wawrzyczny" <email@hidden>
> To: "Sako!" <email@hidden>
> Cc: <email@hidden>; "Chuck Hill"
> <email@hidden>
> Sent: Monday, November 08, 2004 1:59 AM
> Subject: Re: EOF inserts PK automatically
>
>
> >
> > On 06/11/2004, at 23:10, Sako! wrote:
> >
> > >>> before i call EC.SaveChanges(). another Application has already
> > >>> inserted a row in the Table with the same PK. after
> that WO tries to
> > >>> insert row with invalid PK.
> > >>> this problem is also explaind in the WO documentation
> unfortunately
> > >>> without really good solution :(
> > >>>
> > >> I don't know where you got that, its wrong. The real PK
> is generated
> > >> during save changes as part of a transaction. There is
> no danger of
> > >> duplication. PK numbers can be skipped but never duplicated.
> > >>
> > > I think i miss something or something is here wrong.
> > > When i don t set the PK as a ClassProperty, EOF creates
> its own table
> > > "EO_PK_TABLE" in the database, and saves the last PK in the column
> > > pk.
> > > Another applications like ACCESS (what i really have as another
> > > application) for example do not use this technique.
> > >
> > > let me give an example:
> > > 1. EOF adds a row with the PK "27", and CHANGES the pk
> column in
> > > the table EO_PK_TABLE to "27"
> > > 2. ACCESS adds a row with the PK "28".
> > > 3. EOF does not mention what happens to the table and pk. tries to
> > > write with a PK "28" <== which is already used.
> > >
> > > Mr. Chuck, i know you are experienced developer here, but
> I am sure
> > > what I am telling you and its 100% correct.
> > >
> > > I cant change ACCESS now. its expensive and complicated.
> > > WO must be flexible with the database and ACCESS.
> > > So I thought I use the database itself.
> > > There is a feature in MS-SQL <IDENTITY>, what ALWAYS allows the
> > > database to create the PK automatically.
> > > The problem is, this works only if all applications never try to
> > > write in the PK column.
> > > Its possible and easy to make ACCESS stop write in the PK
> column. And
> > > now my question: "how can i make EOF stop inserting the PK?"
> > >
> > > This PK conflict is even in the WO books a big problem,
> even Apple has
> > > no good suggestion for that.
> > > If you have any suggestions for me please let me know.
> >
> > 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 think what you're asking for is how to stop WebObjects
> from trying to
> > generate the PK and make it use the SQL auto-increment
> feature... and
> > the answer is, you cannot.
> bad for me :)
>
> >
> >
> > 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