Search in sources :

Example 1 with QueryBasedValueHolder

use of org.eclipse.persistence.internal.indirection.QueryBasedValueHolder in project jmix by jmix-framework.

the class JpaLazyLoadingListener method processOneToOneValueHolder.

protected void processOneToOneValueHolder(Object owner, MetaProperty property, LoadOptions loadOptions) {
    Object originalValueHolder = getSingleValueHolder(owner, property.getName());
    if (originalValueHolder != null && !(originalValueHolder instanceof AbstractValueHolder)) {
        AbstractValueHolder wrappedValueHolder = null;
        if (metadataTools.isOwningSide(property)) {
            QueryBasedValueHolder queryBasedValueHolder = unwrapToQueryBasedValueHolder(originalValueHolder);
            if (queryBasedValueHolder != null) {
                Object entityId = getEntityIdFromValueHolder(queryBasedValueHolder);
                wrappedValueHolder = new SingleValueOwningPropertyHolder(beanFactory, (ValueHolderInterface) originalValueHolder, owner, property, entityId);
                wrappedValueHolder.setLoadOptions(LoadOptions.with(loadOptions));
            }
        } else {
            // noinspection ConstantConditions
            wrappedValueHolder = new SingleValueMappedByPropertyHolder(beanFactory, (ValueHolderInterface) originalValueHolder, owner, property);
            wrappedValueHolder.setLoadOptions(LoadOptions.with(loadOptions));
        }
        setSingleValueHolder(owner, property.getName(), wrappedValueHolder);
    }
}
Also used : ValueHolderInterface(org.eclipse.persistence.indirection.ValueHolderInterface) QueryBasedValueHolder(org.eclipse.persistence.internal.indirection.QueryBasedValueHolder)

Example 2 with QueryBasedValueHolder

use of org.eclipse.persistence.internal.indirection.QueryBasedValueHolder in project jmix by jmix-framework.

the class JpaLazyLoadingListener method processManyToOneValueHolder.

protected void processManyToOneValueHolder(Object owner, MetaProperty property, LoadOptions loadOptions) {
    Object originalValueHolder = getSingleValueHolder(owner, property.getName());
    if (originalValueHolder != null && !(originalValueHolder instanceof AbstractValueHolder)) {
        QueryBasedValueHolder queryBasedValueHolder = unwrapToQueryBasedValueHolder(originalValueHolder);
        if (queryBasedValueHolder != null) {
            Object entityId = getEntityIdFromValueHolder(queryBasedValueHolder);
            AbstractValueHolder wrappedValueHolder = new SingleValueOwningPropertyHolder(beanFactory, (ValueHolderInterface) originalValueHolder, owner, property, entityId);
            wrappedValueHolder.setLoadOptions(LoadOptions.with(loadOptions));
            setSingleValueHolder(owner, property.getName(), wrappedValueHolder);
        }
    }
}
Also used : QueryBasedValueHolder(org.eclipse.persistence.internal.indirection.QueryBasedValueHolder)

Example 3 with QueryBasedValueHolder

use of org.eclipse.persistence.internal.indirection.QueryBasedValueHolder in project eclipselink by eclipse-ee4j.

the class IndirectSetTest method setUp.

/**
 * set up the test fixture:
 */
@Before
public void setUp() {
    list = setUpList();
    Object temp = new HashSet<>(list);
    ValueHolderInterface vh = new QueryBasedValueHolder(new ReadAllQuery(), new DatabaseRecord(), new TestSession(temp));
    if (cls == null) {
        testList = IndirectCollectionsFactory.createIndirectSet();
    } else {
        try {
            testList = cls.getConstructor().newInstance();
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
    testList.setValueHolder(vh);
    if (useListener) {
        testListLsn = new Listener();
        testList._persistence_setPropertyChangeListener(testListLsn);
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) ValueHolderInterface(org.eclipse.persistence.indirection.ValueHolderInterface) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) HashSet(java.util.HashSet) QueryBasedValueHolder(org.eclipse.persistence.internal.indirection.QueryBasedValueHolder) Before(org.junit.Before)

Example 4 with QueryBasedValueHolder

use of org.eclipse.persistence.internal.indirection.QueryBasedValueHolder in project eclipselink by eclipse-ee4j.

the class IndirectListTest method setUp.

/**
 * set up the test fixture:
 * 1. an IndirectList based on a Vector
 */
@Before
public void setUp() {
    list = setUpList();
    Object temp = new Vector<>(list);
    ValueHolderInterface vh = new QueryBasedValueHolder(new ReadAllQuery(), new DatabaseRecord(), new TestSession(temp));
    if (cls == null) {
        testList = IndirectCollectionsFactory.createIndirectList();
    } else {
        try {
            testList = cls.getConstructor().newInstance();
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
    testList.setValueHolder(vh);
    if (useListener) {
        testListLsn = new Listener();
        testList._persistence_setPropertyChangeListener(testListLsn);
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) ValueHolderInterface(org.eclipse.persistence.indirection.ValueHolderInterface) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) Vector(java.util.Vector) QueryBasedValueHolder(org.eclipse.persistence.internal.indirection.QueryBasedValueHolder) Before(org.junit.Before)

Example 5 with QueryBasedValueHolder

use of org.eclipse.persistence.internal.indirection.QueryBasedValueHolder in project eclipselink by eclipse-ee4j.

the class IndirectMapTest method setUp.

/**
 * set up the test fixture:
 * 1. an IndirectMap based on a Hashtable
 */
@Before
public void setUp() {
    map = this.setUpMap();
    Object temp = new Hashtable(map);
    ValueHolderInterface vh = new QueryBasedValueHolder(new ReadAllQuery(), new DatabaseRecord(), new TestSession(temp));
    if (cls == null) {
        testMap = IndirectCollectionsFactory.createIndirectMap();
    } else {
        try {
            testMap = cls.getConstructor().newInstance();
        } catch (ReflectiveOperationException e) {
            throw new RuntimeException(e);
        }
    }
    testMap.setValueHolder(vh);
    if (useListener) {
        testMapLsn = new Listener();
        testMap._persistence_setPropertyChangeListener(testMapLsn);
    }
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) DatabaseRecord(org.eclipse.persistence.sessions.DatabaseRecord) ValueHolderInterface(org.eclipse.persistence.indirection.ValueHolderInterface) Hashtable(java.util.Hashtable) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) QueryBasedValueHolder(org.eclipse.persistence.internal.indirection.QueryBasedValueHolder) Before(org.junit.Before)

Aggregations

QueryBasedValueHolder (org.eclipse.persistence.internal.indirection.QueryBasedValueHolder)7 ValueHolderInterface (org.eclipse.persistence.indirection.ValueHolderInterface)5 PropertyChangeListener (java.beans.PropertyChangeListener)3 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)3 DatabaseRecord (org.eclipse.persistence.sessions.DatabaseRecord)3 Before (org.junit.Before)3 EntityManager (jakarta.persistence.EntityManager)2 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Vector (java.util.Vector)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 IndirectContainer (org.eclipse.persistence.indirection.IndirectContainer)1 IndirectList (org.eclipse.persistence.indirection.IndirectList)1 BatchValueHolder (org.eclipse.persistence.internal.indirection.BatchValueHolder)1 JpaQuery (org.eclipse.persistence.jpa.JpaQuery)1 OneToManyMapping (org.eclipse.persistence.mappings.OneToManyMapping)1 UnidirectionalOneToManyMapping (org.eclipse.persistence.mappings.UnidirectionalOneToManyMapping)1