|
hi,
i have a solution for readonly fields in jdo.
implemented features:
- does not update the database for the readonly
field
- on commit the changed values for readonly fields
are reverted to the cached values. when the same object is reloaded in another
transaction it has the original values for readonly fields.
there are some points i like to
discuss:
- when the same object is reloaded in the current
transaction it has the potentially changed values for readonly fields. is this
acceptable ?
- what about XML, what does readonly mean
there.
sample to clarify the above:
db = jdo.getDatabase();
// read one person and update
it
db.begin(); person = (Person)db.load(Person.class,new Integer(2)); System.out.println(person); person.setGeburtsDatum(new Date()); person.setTest(1234); // attribute test is readonly , value in database is 12 // read same person in current Transaction person = (Person)db.load(Person.class,new Integer(2)); System.out.println(person); // attribute test contains 1234 !!! db.commit(); // read same person in new Transaction db.begin(); person = (Person)db.load(Person.class,new Integer(2)); System.out.println(person); // attribute test contains 12 ! db.commit(); db.close(); jakob
|
