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

Support embeddable object with 1-N (non-relation) field with join table #138

Closed
andyjefferson opened this issue Nov 9, 2016 · 2 comments
Milestone

Comments

@andyjefferson
Copy link
Member

andyjefferson commented Nov 9, 2016

If we have an embedded object and that object has a 1-N field (either relation, or Collection of some basic type) this implies having a join table for the related object(s). The join table needs a FK back to the owner, but in this case the owner object has no such 'id' and would have to navigate back to the owner that it is embedded in. This is not currently fully supported, but we could one day. See also http://www.datanucleus.org/servlet/jira/browse/NUCRDBMS-989

Need to consider the following situation also.

@PersistenceCapable
@table(name="TABLE_A")
class A
{
@PrimaryKey
long id;

@Embedded
B b;

}

@PersistenceCapable
class B
{
String name;

@JoinTable(name="TABLE_B_VALUES")
Set<String> values;

}

If class B is "embeddedOnly" then we will have TABLE_A and TABLE_B_VALUES.
If class B is not "embeddedOnly" then we will have TABLE_A, TABLE_B, TABLE_B_VALUES and the owner mapping of TABLE_B_VALUES will be confused because it needs datastore-id when used from owner B, and application-id (long) when used from owner A (with B embedded into A).

@andyjefferson
Copy link
Member Author

Still needs tests adding, and either cater for multiple points of embedding, or raise separate issue for that

@andyjefferson andyjefferson reopened this Nov 13, 2016
@andyjefferson andyjefferson added this to the 5.0.5 milestone Nov 14, 2016
@andyjefferson
Copy link
Member Author

See #139 for the ability to embed in multiple owners.

@andyjefferson andyjefferson changed the title Support embeddable object with 1-N field with join table Support embeddable object with 1-N (non-relation) field with join table Dec 6, 2016
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

1 participant