I am not an OO expert nor an experienced programmer, so I am not going to argue with you. It's just a model I made a while ago. The model is also used by the GUI and this GUI is almost finished now. I am not keen on reimplementing parts of the GUI, I hope you understand this. But I definitely want to use Castor as I think it is the easiest way to make objects persistent.IMO, these types of design decisions should be avoided. I've run into so many bad design decisions which were due directly to what if situations that never took place. This is addressed by an XP principle to which I subscribe highly - build only what you need now; do not build for what if situations in the future unless there is a damn good reason for doing so.
Well, this is the client code:At any rate, the troubleshooting alternative I spoke of deals with determining why the Sleeve object is seen by Castor as having been changed. If we can determine why this is occurring, then this would allow the incorrectly generated SQL to never be executed. So the only object that's being updated is the MediumContainer, correct?
db.begin();
List l = worker.execute("SELECT o FROM kws.mediadb.business.Sleeve o");
Sleeve sleeveToUpdate = (Sleeve)l.get(0);
sleeveToUpdate = (Sleeve)db.load(sleeveToUpdate.getClass(), sleeveToUpdate.getId());
sleeveToUpdate.setTitle("123");
db.commit();
So I select the first sleeve returned by the query and update the title field to "123". The titel field belongs to the MediumContainer obejct however. So Castor thinks the Sleeve has changed, while in fact only the MediumContainer has changed.
I'm using the phantom-framework, attached you can find all relevant code. As you can see the BusinessObject extends the AbstractJDOObject. The AbstractJDOObject implements timestampable. All other objects, such as MediumContainer and Medium just extend BusinessObject, so indirectly they implement timestampable as well.I'm guessing that Castor's cache sees the Sleeve object as having been changed when, in fact, it hasn't changed. Concerning the cache, if the Sleeve object implements Timestampable we could determine what the timestamp looks like via the Timestampable methods jdoGetTimeStamp() and jdoSetTimeStamp(). Does Sleeve implement Timestampable? If not, I'll need to place some debugging code within Castor to make this determination.
Thanks for your help.
regards,
Kenneth
_________________________________________________________________
mediadb.zip
Description: Zip archive
