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