Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDO @Join relationships not persisted #27

Closed
dhakehurst opened this issue Apr 6, 2017 · 6 comments
Closed

JDO @Join relationships not persisted #27

dhakehurst opened this issue Apr 6, 2017 · 6 comments

Comments

@dhakehurst
Copy link

dhakehurst commented Apr 6, 2017

I have two classes, as below.

When I store (makePersistent) an instance of the container,
the items do not get persisted.

This works fine with datanucleus-rdbms

@PersistenceCapable
class Container {
@PrimaryKey
@Persistent
public String getIdentity() {...}

@Persistent(defaultFetchGroup = "true")
@Join
public List<Item> getItems() {...}

}

@PersistenceCapable
class Item {
@PrimaryKey
@Persistent
public String getIdentity() {...}
}

@andyjefferson
Copy link
Member

What you're expecting there I've no idea. See the documentation for what is persisted
http://www.datanucleus.org/products/accessplatform_5_1/datastores/datastores.html#neo4j

Indeed Node + Relationship + Node are persisted, and they are read back in on getObjectById or query operations (in all of my tests).

There is no such concept of a "join table" supported so putting @Join makes no difference to anything. If you mean you want to contribute some support for persisting @Join in some other way then this is where you link your pull requests

@dhakehurst
Copy link
Author

see
http://www.datanucleus.org/products/accessplatform_4_1/jdo/orm/one_to_many_list.html
1 to N relationships are either by Foreign-Key or Join Table

I was using and rdbms before switching to Neo4j.
JDO is supposed to mean I don't need to know what type of db is being used.
So the same JDO annotated classes should be useable irrespective of the db type.
Yes ?

Maybe the 'Join' is not necessary for Neo4j, but it does seem to be needed for RDBMS.

@andyjefferson
Copy link
Member

The JDO spec contains some ORM aspects (that apply to RDBMS only), and some that are general. The JDO spec doesn't make a clear definition of how they should be applied because every database is different. The ORM aspects of the spec always apply to RDBMS, that part is defined in the JDO spec, but they do not always apply to "NoSQL". If you wanted to define some of what applies to NoSQL, you go to https://issues.apache.org/jira/browse/JDO-651

With current DN handling you don't need to know what type of DB is being used. It persists objects to Neo4j irrespective of what you put for @Join, and just ignores that metadata. There is nothing in the JDO spec that says you should invent some intermediate object (a Node in Neo4j), and then have a Relationship from A to A_B, and then a Relationship from A_B to B. That is what RDBMS requires.

@dhakehurst
Copy link
Author

Still doesn't explain why the second object is not persisted.

Please re open and I will create a test case

@andyjefferson
Copy link
Member

Did you read the link i gave? If I have an object A with a collection of B's it persist all objects as Nodes, and has Relationship objects between them.

@dhakehurst
Copy link
Author

Yes, of course read it!

I will create a test case and make a new issue seeing as it has nothing to do with the Join annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants