[hibernate-dev] [OGM] [Neo4J] AssociationKey and missing info for associations mapping

Pawel Kozlowski pkozlowski.opensource at gmail.com
Mon May 28 16:34:06 EDT 2012


hi!

I'm progressing on the implementation of the Neo4j integration for
Hibernate OGM and I think that I've bumped into a missing piece of
info when mapping associations.

Let me explain: in Neo4j (in any grap database really) it would be
very natural to map an association of 2 entities as a relationship
among 2 nodes (where each node represents an entity). This was the
path I was taking but then I've realized that I'm probably missing a
piece of info that would allow me to connect 2 nodes together.

Looking at the OGM docs and debugging I've realized that (at least
today) I've got only following pieces of info available in the
AssociationKey:
- table name for the association owning entity
- a set of column names / column values corresponding to a primary key
of the target entity.

Moreover, 'columnNames' in AssociationKey got a predefined names in
form of [o:property name]_[t:pk_field1], [o:property
name]_[t:pk_field2] etc. (where 'o' stands for the owning entity and
't' for the target one).

What I would like to (ideally) do is to map an association as a Neo4j
relationship between 2 nodes (each node corresponding to an entity)
where the relationship would be named as [o:property name].
Unfortunately I'm facing 2 issues:

1) I don't have access to EntityKey's of 2 ends of the association (or
at least I don't know how to access this info). I've noticed that
Emmanuel works on providing a valid EntityKey inside a AssociationKey
(https://github.com/emmanuelbernard/hibernate-ogm/tree/OGM-177) - I
guess it would solve half of my problems :-)

2) Naming strategy of column names in AssociationKey ([o:property
name]_[t:pk_field1]) makes it difficult to get a hand on a [property
name] - I would like to avoid splitting on '_' as it is very fragile.

I'm still quite new to Hibernate OGM so I'm not sure if I'm
approaching the problem from the right angle. I would really like to
keep mapping as natural to Neo4j / graph DB way of thinking so I would
be grateful for any feedback.

Cheers,
Pawel


More information about the hibernate-dev mailing list