Hello Franck,
I have been hacking quite a lot today. Unifying Session and
DataSet. Needs more thought.
Renamed
1. SDataSet to SDataSetTemp
2. SSession to SDataSet
Then created SPersisterDatabase that extends SPersister.
Goal to unify SDataSetTemp and SDataSet into the same class, but with
database things going into SPersisterDatabase.
Clearly we want the .database code in a separate jar from the .record
SDataSet.
Things like having a default session attached to the thread has
nothing to do with the database and can go in .record instead of .database.
Unifying means that the user can write things like
ses.findOrCreate(...)
and ses IS a data set, no delegating all the methods.
That was the motivation.
A database DataSet is then just a DataSet that has a
SPersisterDatabase SPersister.
But...
The current code creates a new SDataSetTemp every time a transaction
begin()s. And the reference is nulled after commit(). This
obviously cannot happen after unification. Instead, we would destroy
the records and cache maps as in 2.*.
After unification, "detaching" a dataset just means changing the
persister to be the trivial non-database one, and clearing the thread local.
I still think the merge is a good idea, but I will stop short of
actually doing it. It would then be quite easy to undo the renames
if we changed our minds. We are biting off a lot more than I wanted
to, but getting these structures right is critical because they are
difficult to change later.
(In some way we have come around in a big circle. They were unified
in 2.*, then we split out DataSet, then we unified them again in a
different way but with the persister split out.)
(There are, of course, far to many public things at the moment. Once
everything is moved need to restrict it all again.)
Anthony
Dr Anthony Berglas, anthony@... Mobile: +61 4 4838 8874
Just because it is possible to push twigs along the ground with ones nose
does not necessarily mean that is the best way to collect firewood.