Written by Gunther Schadow.
Release 1.0 - 12/6/1999 -- dedicated to Saint Nikolaus
This is an early release of the persistence broker. It works for me so far, but it is not yet robust, especially regarding concurrency and features implemented. I don't have alpha and beta release stages, but consider this alpha. THIS SOFTWARE IS PROVIDED AS IS, WITH NO WARRANTY WHATSOEVER, EXPRESS OR IMPLIED. DO NOT USE FOR MISSION CRITICAL DATA UNTIL YOU HAVE REVIEWED AND TESTED THE CODE.
Every class whose instances are to be persistent must inherit from the class PersistentObject. Every persistent object has the methods:
The PersistenceBroker is an interface with the user methodvoid save()
and soon some query (by example) methods. A preliminary and limited implementation ofPersistentObject load(java.lang.Class, OID oid)
is now avaialable.ObjectSet PersistentObject.query(PersistenceBroker pb)
With RMRS/persist you can define the mapping of java classes to tables and java fields to columns in the data base (dictionary, two simple tables ps_class and ps_field.) For field mapping you can choose between the following kinds
The nice thing about the RMRS/persist package is that the client objects don't have to have any special interface (like in COBRA.) Rather, just like JOS, any field can be stored and retrieved from the data base without a special accessor method, and even if it's private. The only requirement is that the field is defined in the data dictionary. If a non-transient field is not in the dictionary, you get a warning but it still continues. The only stuff that persistent objects may want to implement is a special static constructor method so that the default constructor can be private. And a call-back method
that is called by the broker when a persistent object awakes from it's sleep (to recalculate transient values, etc.) So, RMRS/persist it's very seamless.void notifyRestored()
For to-many associations the multiple distal objects must be kept in an ObjectSet. An ObjectSet is like a Vector that allows on-demand object loading. The ObjectSet may contain either OIDs or Objects. Before an element of ObjectSet is returned an OID is resolved into an object. This implements a limited way to do on-demand loading, that is, load objects into memory only when needed.
The best way to get started with this is have a look into the test subdirectory. You will find one test scenario that implements inheritance, inlining, to-one, and to-many mappings. Including the data base initialization. Tested with HypersonicSQL, PostgreSQL, and MySQL (where there is a minor bug.)
I'm hoping that some other pair of eyes and hands might whant to check the concurrency behavior of this package (which I am currently not too concerned with) The goal is to make it thread safe on the Java side and concurrency-safe on the DB side.
On to Java generated API documentation.
See example source code.