• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: EOF inserts PK automatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOF inserts PK automatically


  • Subject: Re: EOF inserts PK automatically
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 19 Nov 2004 11:35:38 -0800

Perhaps it is worth wading into this one more time. Using database generated unique numbers (a.k.a. sequences) is not a problem. As Benjamin points out below, it is just a matter of some code in the plugin or even in your app as a delegate method to one of the EOAccess classed (I forget which off the top of my head and am too lazy to look it up).

Another way that databases generate the primary key is what is often referred to as an identity column. The values in this column are filled in by the database when the row is inserted. The method of primary key generation can NOT be used with WO, or any other environment that does not use some proprietary database access method. If you think about it you will quickly see why it won't work. You have some data, but no primary key. You insert it, and the PK is created by the database and added to the data. But _you_ are never told what the PK is. SQL INSERT only returns a success or failure code, not a copy of the inserted data. So now you have the data, but not the primary key (which you have no way of knowing) and the database has the same data _and_ the primary key. Now, how are you going to update that exact row if you don't know the PK? You could the row where all the other values are the same, but there is no guarantee that this defines a unique row. In many, many cases it does not define a unique row, it defines a set of rows. How are you going to know which one the the one you just inserted? In a nutshell, you can't.

Your only hope for using this with WO is to:
1. Somehow force it to not generate the PK and use null as the insert value. If the database takes 0 as null, then this is easy
2. After insertion _immediately_ tell the ec to forget the object (not invalidate, forget).
3. The user will then have to somehow fetch some data that includes this new object.


Me, I'd stay far away from that.

Chuck


On Nov 19, 2004, at 10:58 AM, Benjamin J Doherty wrote:

On Nov 19, 2004, at 3:33 AM, Sako! wrote:

if you read my first or second post, you will mention i use MS-SQL.
and tipically Apple talks about all the world ECCEPT MS-SQL.
"Apple hates Microsoft" why do i wonder?

Mention this sentence in the site:
" It doesn't work if the database includes rows that are inserted by
non-Enterprise Objects applications."
so what the hell do i have as a solution then? non.
this sentence tells me i have to forget the PK feature in EOF.
Ok fine. my first question was and still:  how can i force EOF to stop
trying to use this week pk feature(s)?


I don't know ANYTHING about MS-SQL, but I assume that like most databases it has some support for sequences. If you want to use these instead of that (agreed) weak EO_PK_TABLE, just subclass the MS-SQL adapter, rework the code from the PostgresqlPlugIn from Project Wonder (which uses sequences to generate primary keys), and voilĂ  sommes nous.


But I wasn't following the whole discussion, so I admit I may not be on the nose here.

Benjamin J Doherty
sole proprietor
!&# Group
www.bangpound.org
+1-773-934-4236
--
Practical WebObjects - a book for intermediate WebObjects developers who want to increase their overall knowledge of WebObjects, or those who are trying to solve specific application development 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


References: 
 >RE: EOF inserts PK automatically (From: "Ruenagel, Frank" <email@hidden>)
 >Re: EOF inserts PK automatically (From: Marek Wawrzyczny <email@hidden>)
 >Re: EOF inserts PK automatically (From: "Sako!" <email@hidden>)
 >Re: EOF inserts PK automatically (From: Benjamin J Doherty <email@hidden>)

  • Prev by Date: Re: EOF inserts PK automatically
  • Next by Date: Re: Problem with download links in Panther but not in Jaguar
  • Previous by thread: Re: EOF inserts PK automatically
  • Next by thread: Re: EOF inserts PK automatically
  • Index(es):
    • Date
    • Thread