RE: [newbie] ODMG API : updating an object's primary key.
ok. Thank you. -Message d'origine- De : Thomas Dudziak [mailto:[EMAIL PROTECTED] Envoyé : mercredi 9 février 2005 13:52 À : OJB Users List Objet : Re: [newbie] ODMG API : updating an object's primary key. But as far as OJB and the database is concerned, it is a new one, because they cannot determine to which 'old' one it corresponds. The problem here is that OJB and the database use object equality (if two objects are equal as determined by equals()/hashCode()) whereas you want to use identity (same java object as determined by ==, i.e. location in memory). So you either got to delete the old object/row and then insert the new one, or introduce a separate primary key. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [newbie] ODMG API : updating an object's primary key.
But as far as OJB and the database is concerned, it is a new one, because they cannot determine to which 'old' one it corresponds. The problem here is that OJB and the database use object equality (if two objects are equal as determined by equals()/hashCode()) whereas you want to use identity (same java object as determined by ==, i.e. location in memory). So you either got to delete the old object/row and then insert the new one, or introduce a separate primary key. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [newbie] ODMG API : updating an object's primary key.
Actually the concept of primary key is not always used in a database. Let's imagine a table person with fields firstname and lastname but no id. As OJB needs a primary key I will use the couple (firstname,lastname) as a primary key for the mapping. But if I change the property firstname in the java object, it is still the same object and not a new one. -Message d'origine- De : Thomas Dudziak [mailto:[EMAIL PROTECTED] Envoyé : mercredi 9 février 2005 13:28 À : OJB Users List Objet : Re: [newbie] ODMG API : updating an object's primary key. Why would you want to do that ? The primary key identifies the object uniquely, so if you change the value of the corresponding java field(s), then OJB and the database think that you have created a new instance of the class/new row in the table. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [newbie] ODMG API : updating an object's primary key.
Why would you want to do that ? The primary key identifies the object uniquely, so if you change the value of the corresponding java field(s), then OJB and the database think that you have created a new instance of the class/new row in the table. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]