Search in sources :

Example 1 with ReadAllQuery

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;
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Example 2 with ReadAllQuery

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;
    }
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Example 3 with ReadAllQuery

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);
}
Also used : Expression(org.eclipse.persistence.expressions.Expression) ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 4 with ReadAllQuery

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;
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery) InMemoryQueryIndirectionPolicy(org.eclipse.persistence.queries.InMemoryQueryIndirectionPolicy)

Example 5 with ReadAllQuery

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();
    }
}
Also used : ReadAllQuery(org.eclipse.persistence.queries.ReadAllQuery)

Aggregations

ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)440 Expression (org.eclipse.persistence.expressions.Expression)278 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)265 List (java.util.List)202 EntityManager (jakarta.persistence.EntityManager)135 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)119 Vector (java.util.Vector)112 ArrayList (java.util.ArrayList)88 Spatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial)82 SpatialParameters (org.eclipse.persistence.expressions.spatial.SpatialParameters)81 Employee (org.eclipse.persistence.testing.models.jpa.advanced.Employee)62 ReportQuery (org.eclipse.persistence.queries.ReportQuery)57 SimpleSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.SimpleSpatial)47 WrappedSpatial (org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial)44 SQLReader (org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader)41 JGeometry (oracle.spatial.geometry.JGeometry)30 CriteriaBuilder (jakarta.persistence.criteria.CriteriaBuilder)29 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)28 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)27 Query (jakarta.persistence.Query)25