> In a Document approach, there is no (useful) notion of
association either but one can gather a set of elements under a property name. This is
useful for collection of embedded and collection of associated entities that one want to
embed. But the property name under which we would set the collection is not property
rendered in the table + column(s) approach. That's why associationKey has
getCollectionRole(); I wish I had a better approach but today that's what we've
got.
While checking under debugger I can see that the 'collectionRole'
field is not filled in AssociationKey (it is null). I can observe this
with the master branch of
https://github.com/hibernate/hibernate-ogm.
Is there any other repo / branch where the work on the collectionRole
is more advanced? Or am I missing sth here?
Yes that's OGM-177 :(
You can start by using @ElementCollection instead of @OneToMany. You will get the
information you are looking for in this situation.
> - In Neo4J, is there a notion of (optional) schema where we would not need to repeat
that we are linking from A to B in property foo?
Hmm, not sure if I'm reading you correctly here, but I'm not aware of
any such optional schema... Not sure if by A,B here you are referring
to node instances or node "classes". Because - as far as I'm aware -
in Neo4j you don't have any concept of a Node type. Node is just a
Node, it differs from other nodes only by:
- its internal id (really internal, assigned by Neo4j and not overradible)
- its properties
- its relations (associations)
That answers my question.
> We will need at some point to introduce the notion of @AssociationName to separate
the object model from the association representation in document and graph datastores.
Hmm, ok, I'm not sure I can see imediatelly a need for the
@AssociationName. Let's assume I've got a User entity that has 2
OneToOne associations to an Address entity (say, stored in homeAddress
and workAddress fields). Given such object model I would map a user to
a Node, 2 addresses to a nodes and would have the following
relationships:
UserNode(id=user1)--homeAddress-->AddressNode(id=adress1)
UserNode(id=user1)--workAddress-->AddressNode(id=adress2)
Not sure if I'm making myself clear here, if not I can prepare a ghist
+ screen shoots from Neo4j editor to illustrate it better.
Understood, @AssociationName would be to decorrelate the property name homeAddress from
the association name in case the object model name changes but you don't want to
change all your data in your database.
> Pawel, I'd recommend you use collectionRole for your
association name. Let me know if that works even in the bidirectional case.
This should work in the bidirectional case, just need to understand
why it is null in the current implementation. Do you have any idea
about what might be going on here?
OGM-177 basically :)