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 storage/retrieval of embedded objects with collections of non-embedded persistables #171

Open
andyjefferson opened this issue Dec 14, 2016 · 0 comments

Comments

@andyjefferson
Copy link
Member

andyjefferson commented Dec 14, 2016

Take these classes

@PersistenceCapable
public class A
{
    B b;
}

@PersistenceCapable(embeddedOnly="true")
public class B
{
    Collection<C> elements;
}

@PersistenceCapable
public class C
{
}

so we have tables A and C, with B embedded into table A. The table C would need to have a FK across to table A for "b.elements".

Firstly, with RDBMS, we dont allow this since don't currently handle the "b.elements" as the SCO store to enable use to navigate across the FK, and we don't provide for creation of the FK in C back to A.

We also currently have an assumption that when we retrieve an embedded object that it is fully loaded (all fields). If we allow fields containing non-embedded (persistable) objects then this breaks down. When we do
A a = em.find(A.class, id);
if the object is in the L2 cache then it pulls in all fields, since all are present in the L2 cache. If it isn't in the L2 cache then it will pull in the fields loadable in the basic FetchRequest (i.e all except the Collection of C). This is never recovered from since it thinks the field is loaded (StateManager.initForEmbedded). Which in turn populates the L2 cache with an object without the nested Collection etc.

@andyjefferson andyjefferson changed the title Support retrieval of embedded objects with collections of non-embedded Support storage/retrieval of embedded objects with collections of non-embedded persistables Feb 20, 2022
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