Hi there- my company has settled on using OJB as a replacement for a
homegrown and badly outdated persistence layer. 

Something that we have not quite figured out is how we will handle our
existing database schema, which uses database-generated primary key fields
(we call "ndx", declared as type "IDENTITY" since we're using SQL server).

I did a fair amount of searching and found where a user had helpfully posted
a PersistenceBrokerAware implementation where the key value is immediately
selected out of the database as soon as the row is inserted. 

I could use this, but something I would want to do is make it select the MAX
primary key by the values. Otherwise if you have more than one record where
the non-primary key fields are all the same, you get the wrong key.

Aside from that, I kind of dislike having to do an insert and then a select
just to get the key. What do you do if one of the columns is a TEXT? What if
the ONLY non-primary key column is a TEXT?

Something I prototyped a while back, just to see if it worked, was to use an
updatable cursor for inserting the new row. As soon as you execute the
insertRow() method, the ndx value did indeed automatically appear in my
cursor, which I could then set in the local data object.

I looked through the persistence broker code, and im wondering if this
approach would be pretty much impossible, given that there's no resultset to
use to make the insert, rather, we're relying on the sql generator to create
the insert statement.

Any ideas on how we could achieve this? I have no problems with the idea of
using the sequence generator to create the NDX values for me, however, we
are going to have to phase out the old persistence layer gradually for
existing code, so they will have to coexist for some period of time, and the
old code will still be creating records in the database, so we cant just go
and change all the IDENTITY fields to INTEGER. Worst case scenario, we can
use the provided code that really does the select after the insert. After
all, its what we're doing right now already (I just dont like it :)

thanks-
Dave Mitchell



+---------------------------------------------------------+ 
This message may contain confidential and/or privileged information.  If you
are not the addressee or authorized to receive this for the addressee, you
must not use, copy, disclose or take any action based on this message or any
information herein.  If you have received this message in error, please
advise the sender immediately by reply e-mail and delete this message.
Thank you for your cooperation.
+---------------------------------------------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to