Search in sources :

Example 6 with FetchGroup

use of org.eclipse.persistence.queries.FetchGroup in project cuba by cuba-platform.

the class FetchGroupManager method setView.

public void setView(JpaQuery query, String queryString, @Nullable View view, boolean singleResultExpected) {
    Preconditions.checkNotNullArgument(query, "query is null");
    if (view != null) {
        AttributeGroup ag = view.loadPartialEntities() ? new FetchGroup() : new LoadGroup();
        applyView(query, queryString, ag, view, singleResultExpected);
    } else {
        query.setHint(QueryHints.FETCH_GROUP, null);
    }
}
Also used : AttributeGroup(org.eclipse.persistence.queries.AttributeGroup) FetchGroup(org.eclipse.persistence.queries.FetchGroup) LoadGroup(org.eclipse.persistence.queries.LoadGroup)

Example 7 with FetchGroup

use of org.eclipse.persistence.queries.FetchGroup in project cuba by cuba-platform.

the class EclipseLinkDescriptorEventListener method postRefresh.

@Override
public void postRefresh(DescriptorEvent event) {
    if (event.getObject() instanceof FetchGroupTracker) {
        FetchGroupTracker entity = (FetchGroupTracker) event.getObject();
        FetchGroup fetchGroup = entity._persistence_getFetchGroup();
        if (fetchGroup != null && !(fetchGroup instanceof CubaEntityFetchGroup))
            entity._persistence_setFetchGroup(new CubaEntityFetchGroup(fetchGroup));
    }
}
Also used : FetchGroupTracker(org.eclipse.persistence.queries.FetchGroupTracker) FetchGroup(org.eclipse.persistence.queries.FetchGroup)

Example 8 with FetchGroup

use of org.eclipse.persistence.queries.FetchGroup in project cuba by cuba-platform.

the class EclipseLinkDescriptorEventListener method postBuild.

@Override
public void postBuild(DescriptorEvent event) {
    if (event.getObject() instanceof BaseGenericIdEntity) {
        BaseEntityInternalAccess.setNew((BaseGenericIdEntity) event.getObject(), false);
    }
    if (event.getObject() instanceof FetchGroupTracker) {
        FetchGroupTracker entity = (FetchGroupTracker) event.getObject();
        FetchGroup fetchGroup = entity._persistence_getFetchGroup();
        if (fetchGroup != null && !(fetchGroup instanceof CubaEntityFetchGroup))
            entity._persistence_setFetchGroup(new CubaEntityFetchGroup(fetchGroup));
    }
}
Also used : FetchGroupTracker(org.eclipse.persistence.queries.FetchGroupTracker) FetchGroup(org.eclipse.persistence.queries.FetchGroup)

Example 9 with FetchGroup

use of org.eclipse.persistence.queries.FetchGroup in project cuba by cuba-platform.

the class GlobalPersistentAttributesLoadChecker method isLoadedCommonCheck.

protected PropertyLoadedState isLoadedCommonCheck(Object entity, String property) {
    if (entity instanceof BaseGenericIdEntity) {
        BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) entity;
        String[] inaccessibleAttributes = BaseEntityInternalAccess.getInaccessibleAttributes(baseGenericIdEntity);
        if (inaccessibleAttributes != null) {
            for (String inaccessibleAttr : inaccessibleAttributes) {
                if (inaccessibleAttr.equals(property))
                    return PropertyLoadedState.NO;
            }
        }
        if (entity instanceof FetchGroupTracker) {
            FetchGroup fetchGroup = ((FetchGroupTracker) entity)._persistence_getFetchGroup();
            if (fetchGroup != null) {
                boolean inFetchGroup = fetchGroup.getAttributeNames().contains(property);
                if (!inFetchGroup) {
                    // definitely not loaded
                    return PropertyLoadedState.NO;
                } else {
                    // requires additional check specific for the tier
                    return PropertyLoadedState.UNKNOWN;
                }
            }
        }
    }
    return PropertyLoadedState.UNKNOWN;
}
Also used : FetchGroupTracker(org.eclipse.persistence.queries.FetchGroupTracker) BaseGenericIdEntity(com.haulmont.cuba.core.entity.BaseGenericIdEntity) FetchGroup(org.eclipse.persistence.queries.FetchGroup)

Aggregations

FetchGroup (org.eclipse.persistence.queries.FetchGroup)9 FetchGroupTracker (org.eclipse.persistence.queries.FetchGroupTracker)6 MetaClass (com.haulmont.chile.core.model.MetaClass)3 MetaProperty (com.haulmont.chile.core.model.MetaProperty)3 AttributeGroup (org.eclipse.persistence.queries.AttributeGroup)3 LoadGroup (org.eclipse.persistence.queries.LoadGroup)3 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)2 Entity (com.haulmont.cuba.core.entity.Entity)2 Method (java.lang.reflect.Method)2 Preconditions (com.haulmont.bali.util.Preconditions)1 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)1 Range (com.haulmont.chile.core.model.Range)1 BaseUuidEntity (com.haulmont.cuba.core.entity.BaseUuidEntity)1 EmbeddableEntity (com.haulmont.cuba.core.entity.EmbeddableEntity)1 SoftDelete (com.haulmont.cuba.core.entity.SoftDelete)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1 CubaEntityFetchGroup (com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1