I hope this is the correct forum to be posting this to, none of the others really seem to be a fit for this idea/question/seeking of advice.
I am developing a swing 2-tier application which connects directly to the database. Part of this application requires a "distributed blackboard" (what they call it in Hunt and Thomas' The Pragatic Programmer) for users to upload files to. Effectively I suppose what I am aiming for is a Javaspaces style blackboard using hibernate as the persistence mechanism. I can't just use Javaspaces as there's a fair overhead to using it in the first place, and I also want to be able to run the application in standalone (on the one machine) and client-server modes.
I can detect the addition of a file using a HibernateInterceptor (the onSave, onFlushDirty) and send a message via JMS of the class that owns the file (Parent.class), and it's primary key.
On another client I can receive the object added/removed messages from JMS and update the client's collections of the objects (for an add using Session.load(Class, Serializable) and for a remove Session.evict()). However when the receiving client flushes the session I get BatchUpdateFailed exceptions from Hibernate.
I have tried refreshing and merging the Parent persisted instance with the session, and manually manipulating the collection of Child object's associated with it with no luck. I've also tried playing with the version and unsaved-value properties of my classes, however when I do this I get an Exception.
Has anyone out there tried doing a similar collaborative system in Hibernate, or can anyone point out why this approach won't work?
Thankyou.
Last edited by aidos on Fri Jan 19, 2007 10:14 pm, edited 1 time in total.
|