Skip to content

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

Open
@BenDol

Description

@BenDol

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions