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

EAGER collections still become PersistentCollections and are mapped as persistent #122

Open
BenDol opened this issue Sep 19, 2018 · 7 comments

Comments

@BenDol
Copy link

BenDol commented Sep 19, 2018

There should be an option to assume that all ManyToX and OneToX annotation markers are lazy to avoid the issue where there are times an EAGER collection will be a PersistentCollection.

For example, like so:

protected boolean usesLazyLoading(BeanProperty property) {
    if (property != null) {
        boolean assumeLazy = Feature.ASSUME_ANY_MARKER_IS_LAZY.enabledIn(_features)
        // As per [Issue#36]
        ElementCollection ec = property.getAnnotation(ElementCollection.class);
        if (ec != null) {
            return assumeLazy || (ec.fetch() == FetchType.LAZY);
        }
        OneToMany ann1 = property.getAnnotation(OneToMany.class);
        if (ann1 != null) {
            return assumeLazy || (ann1.fetch() == FetchType.LAZY);
        }
        OneToOne ann2 = property.getAnnotation(OneToOne.class);
        if (ann2 != null) {
            return assumeLazy || (ann2.fetch() == FetchType.LAZY);
        }
        ManyToOne ann3 = property.getAnnotation(ManyToOne.class);
        if (ann3 != null) {
            return assumeLazy || (ann3.fetch() == FetchType.LAZY);
        }
        ManyToMany ann4 = property.getAnnotation(ManyToMany.class);
        if (ann4 != null) {
            return assumeLazy || (ann4.fetch() == FetchType.LAZY);
        }
        // As per [Issue#53]
        return !Feature.REQUIRE_EXPLICIT_LAZY_LOADING_MARKER.enabledIn(_features);
    }
    return false;
}
@BenDol
Copy link
Author

BenDol commented Sep 20, 2018

To clarify the issue I'm having, the code that replaces the persistent collection type information with a regular collection, requires that the property pass the usesLazyLoading check and in turn the type never changes for me with my EAGER collection. So either we check the types separate to the serialization write or we just assume that all are lazy.

@BenDol
Copy link
Author

BenDol commented Jan 8, 2019

is there any progress on this issue?

@cowtowncoder
Copy link
Member

@BenDol if someone was working on this, there should be updates here, so I don't think there is or will be update unless someone has an itch.
Unfortunately Hibernate module has no maintainer at this point.

@kamtorocks
Copy link

Why nobody fix it

@cowtowncoder
Copy link
Member

@Leenin you volunteering?

@jackoneall
Copy link

@cowtowncoder I was thinking about picking this up because we could really use ReplacePersistentCollections to work. I was wondering if you agree that this just needs to be covered by the REPLACE_PERSISTENT_COLLECTION feature? I don't see a reason to serialize the Persistent Collection to JSON, even if it was marked as an EAGER fetch when the above feature is enabled.

@cowtowncoder
Copy link
Member

@jackoneall I do not know Hibernate well enough to say either way; but typically when changing behavior it makes sense to add a configuration option, and making it default to old behavior (but allow opt-in for new variation).

But whether a new configuration option is added or not, this change should go in 2.13.0 (and not a patch release) -- master is for 2.13.

If you do have time to do a PR, timing would be good as I am about to release the first (and possibly only) RC for 2.13.0. So there is time to get this change in, and available relatively quickly.

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

No branches or pull requests

4 participants