Re: New (sorta) to WebObjects and looking for some insight.
Re: New (sorta) to WebObjects and looking for some insight.
- Subject: Re: New (sorta) to WebObjects and looking for some insight.
- From: Paul Lynch <email@hidden>
- Date: Mon, 20 Mar 2006 21:45:24 +0000
On 20 Mar 2006, at 20:19, Andrew Satori wrote:
On Mar 20, 2006, at 2:53 PM, Chuck Hill wrote:
Which brings me to the other issue, reverse usage, using EOF with
pre-existing schemas where the Primary Keys are identity (MSSQL)
or serial (PostgreSQL) columns. While *read* seems to work with
these models, update and insert do not. Again, I suspect User
Error, probably along the lines of over complicating things based
upon my background. I'm really just looking for some pointers or
a gently nudge in the right direction.
You can't (easily, with software almost anything is possible given
enough effort) use identity and serial columns with WebObjects.
WO needs to know the PK at the time of save so that it can find
the object again)
I was afraid of that, though both implementation have methods of
getting the newly inserted key back, it means that I'll have to
stick to the hand-coded classes for the preexisting schema's.
Knowing that makes it alot easier to cope with though, It's easy to
get frustrated trying to make something work that won't :-).
There are several ways of getting serial/identity keys to work; these
are really only worth the effort if you are working with a legacy
database, which it sounds like you are. So, to expand on Chuck's
"enough effort" comment... :-)
WO uses a chain of methods to generate a primary key - the first
method to supply a value wins. The top of the chain is when your own
code provides a value, and this is the easiest way (IMHO) to override
primary key generation. The end of the chain is the standard, built
in, eo_pk_table method. In between are several other tricks; the
most robust, general purpose one is to implement
databaseContextNewPrimaryKey in an EODatabaseContext delegate,
although you can also use a stored procedure to generate the key for
you. These are all a little hackish, and can also involve much more
overhead than the standard key generation mechanisms, depending on
what is important to you.
Paul
_______________________________________________
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