Re: SDataSet should handle generated keys
Anthony Berglas <[email protected]>
| Newsgroups | gmane.comp.java.orm.simpleorm |
|---|---|
| Message-ID | <[email protected]> |
Hello Franck, Not what I wanted to hear. The problem is actually deeper. In particular, if you generate keys when records are inserted into the database (as normally done with MS SQL) then you need to be able to hold the records without Primary Keys. All very messy, and I was hoping that we would not have to deal with it for now. I think that right way to do it is to enable records to be put in the cache with null primary keys. They can then be updated at commit time. record.Equals(null, null) would be false. References between records in the dataset can be maintained as direct pointers, the foreign keys will need to be updated on demand. I'll make a start. One alternative for you is to simply pregenerate the ids, and pass them to the client. If they are not needed then just throw them away. That way you do not need to wait for me, although I would like you to test the code. RELATED WORK Hibernate sort of gets away with null primary keys because objects normally only directly reference other object, but bad things happen if one has a hashset of children records. http://msdn.microsoft.com/en-us/library/ks9f57t0.aspx Shows ADO.NET has messy solutions. Give the record a temporary ID, then modify it at commit time. http://www.onjava.com/pub/a/onjava/2006/09/13/dont-let-hibernate-steal-your-identity.html suggests using horrible UUIDs as a solution. (UUID is basically a large random number that can be generated in the client and thus almost certainly be unique.) Anthony At 08:07 AM 11/08/2008, Franck Routier wrote: >Hi, > >I think there is a hole with "records live only in SDataSet" when coming >to generated primary keys: if we want to create a new record that has a >generated pkey, we need a way to create a "temporary" generated key. > >This would also mean we need to replace this key with the true one when >the session will begin. Messy. >This change should also be propagated to referencing records... > >Before we didn't have the problem, as records didn't need to have a >database-like identity until attached. But now they are attached to the >dataset from the begining... > >Any idea on that ? > >Franck > > Dr Anthony Berglas, [email protected] Mobile: +61 4 4838 8874 Just because it is possible to push twigs along the ground with ones nose does not necessarily mean that is the best way to collect firewood. ------------------------------------ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/SimpleORM/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/SimpleORM/join (Yahoo! ID required) <*> To change settings via email: mailto:[email protected] mailto:[email protected] <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
b1990c4.jpg
(image/jpeg, 3.3 KB) - not displayed