Hi Max, I don't like this solution as it relies on adding special attributes to your persistent classes. The OJB philosophy has always been to avoid such things whereever possible.
The OJB solution is like follows: http://jakarta.apache.org/ojb/apidocs/org/apache/ojb/broker/PersistenceBroker.html#store(java.lang.Object,%20org.apache.ojb.broker.util.ObjectModification) This PB method allows you to store object with a hint whether INSERT or UPDATE is needed. The hint is encapsulated in an ObjectModification object. here is an example how the ODMG implementation uses such a hint when commiting objects: http://jakarta.apache.org/ojb/xref/org/apache/ojb/odmg/states/StateNewDirty.html#145 and in ObjectEnvelope: http://jakarta.apache.org/ojb/xref/org/apache/ojb/odmg/ObjectEnvelope.html#371 cheers, Thomas Max Rydahl Andersen wrote: > Hi! > > While looking into Hibernate I found a solution for making it possible for > vanilla java objects to inform OJB if it was New or just dirty. > This is/was a problem concerning when two (or more) threads could have a > "race-condition" regarding using and deleting each others objects. > >>From Hibernate javadoc: > > public void saveOrUpdate(Object object) throws SQLException, > HibernateException > > Either save() or update() the given instance, depending upon the value of > its identifier property. By default the instance is always saved. This > behaviour may be adjusted by specifying an 'unsaved-value' attribute of the > identifier property mapping. > > Here there is a method that can save any kind of object and Hibernate > decides wether it should be an insert(save) or update that should be > performed. The way it does it is that an attribute can be given the special > property of being the one that can tell Hibernate wether it should save or > not - here called an 'unsaved-value' attribute. > > By having such a (or more) special attribute(s) then an object does not need > to implement a special interface... > > Just an idea :) > > /max > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
