[hibernate-dev] summary of our brainstorming about mapping associations on OGM

Sanne Grinovero sanne at hibernate.org
Wed May 18 13:21:06 EDT 2011


OGM is ongoing some refactoring around the associations mapping to be
able to provide similar locking and isolation experience as when using
a traditional database.

An association is mapped as tuples, which represent the columns on the
relational database (the association table);

So each association is identified by :
[tableName - FKcolumnName - FKcolumnValue]
and the value should "point to" the tuples.

In case the association is represented by a List of Set, then the
association table will have primary keys which prevents duplication of
entries:
 - this set of primary keys is going to be the key of the
FineGrainedLockingAtomicMap[1]
 - the elements of the touple not being part of the PK will be the
value used for the same FGLAM
 - by the semantics of FGLAM, this means we can effectively modify the
elements which are identified by the PK, and acquire a lock only on
those "rows", effectively implementing the desired locking.
 - identifying which elements are part of the PK and which are not can
be done at boot time, when figuring the "schema" of the database; it
depends on the kind of relation.

In case we're mapping a Bag, then it seems that we have no alternative
than to lock the whole set of values: as implementation we could use
the existing AtomicMap API from Infinispan.
one new thought:
 - the core reference suggests that adding to a Bag can be quite
efficient as it doesn't need a return value. thinking about that, it
seems possible that the Bag modification doesn't need an eager lock.

In all cases, we're going to use custom types to represent the keys,
so that we can be flexible in changing it and write custom
Externalizers.

Basically, it will take some more time before this is implemented;
some drafts of the previous ideas (now deprecated) can be found at:
https://github.com/emmanuelbernard/hibernate-ogm/tree/atomicmap

[1] - as https://issues.jboss.org/browse/ISPN-1115

Cheers,
Sanne



More information about the hibernate-dev mailing list