use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class EntityManagerImpl method createQueryInternal.
/**
* This method is used to create a query using a EclipseLink Expression and
* the return type.
*/
protected DatabaseQuery createQueryInternal(Expression expression, Class<?> resultType) {
ReadAllQuery query = new ReadAllQuery(resultType);
query.setSelectionCriteria(expression);
return query;
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class EntityManagerImpl method createQueryByExample.
/**
* This method is used to create a query using a EclipseLink by example.
*/
@Override
public jakarta.persistence.Query createQueryByExample(Object exampleObject) {
try {
verifyOpen();
ReadAllQuery query = new ReadAllQuery(exampleObject.getClass());
query.setExampleObject(exampleObject);
return new EJBQueryImpl(query, this);
} catch (RuntimeException e) {
setRollbackOnly();
throw e;
}
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class InMemoryDirectEntity1MTest method test.
@Override
public void test() {
getSession().readAllObjects(DirectEntity1MMapHolder.class);
ReadAllQuery query = new ReadAllQuery(DirectEntity1MMapHolder.class);
ExpressionBuilder holders = query.getExpressionBuilder();
Expression exp = holders.anyOf("directToEntityMap").mapKey().equal(11);
query.checkCacheOnly();
results = (List) getSession().executeQuery(query);
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class GetAllFromIdentityMapTest method newReadAllQuery.
/**
* Create an instance of {@link ReadAllQuery} and initialize it.
*
* @param c entity class
* @return new instance of initialized {@link ReadAllQuery}
*/
private static ReadAllQuery newReadAllQuery(Class<?> c) {
final ReadAllQuery query = new ReadAllQuery(c);
query.conformResultsInUnitOfWork();
query.setInMemoryQueryIndirectionPolicy(new InMemoryQueryIndirectionPolicy(InMemoryQueryIndirectionPolicy.SHOULD_TRIGGER_INDIRECTION));
return query;
}
use of org.eclipse.persistence.queries.ReadAllQuery in project eclipselink by eclipse-ee4j.
the class ReadAllCompletelyBatchedEmployeeTest method test.
/**
* Read employee and clear the cache, test database read.
*/
@Override
public void test() throws Exception {
super.test();
ReadAllQuery query = new ReadAllQuery(Employee.class);
query.addBatchReadAttribute("address");
query.addBatchReadAttribute("manager");
query.addBatchReadAttribute("phoneNumbers");
query.addBatchReadAttribute("managedEmployees");
query.addBatchReadAttribute("projects");
allObjects = (List) getSession().executeQuery(query);
for (Iterator iterator = allObjects.iterator(); iterator.hasNext(); ) {
Employee employee = (Employee) iterator.next();
employee.getAddress();
employee.getManager();
employee.getManagedEmployees().size();
employee.getProjects().size();
employee.getPhoneNumbers().size();
}
}
Aggregations