Package javax.jdo

Examples of javax.jdo.Query.addExtension()


    q = pm.newQuery(
        "select from " + Student.class.getName() + " where "
        + "courses.contains(c) && c.department == 'Biology' && "
        + "grade == 10 order by courses desc");
    q.declareVariables(Course.class.getName() + " c");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute();
      fail("expected exception");
    } catch (JDOUserException jdoe) {
        if (jdoe.getCause() instanceof DatastoreQuery.UnsupportedDatastoreFeatureException) {
View Full Code Here


    q = pm.newQuery(
        "select from " + Student.class.getName() + " where "
        + "courses.contains(c) && c.department == 'Biology' && "
        + "grade == 10 order by c.department");
    q.declareVariables(Course.class.getName() + " c");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute();
      fail("expected exception");
    } catch (JDOUserException jdoe) {
        if (jdoe.getCause() instanceof DatastoreQuery.UnsupportedDatastoreFeatureException) {
View Full Code Here

    assertQueryRequiresUnsupportedDatastoreFeature(baseQuery + "origin > 5 || origin < 2");
  }

  private void assertQueryRequiresUnsupportedDatastoreFeature(String query) {
    Query q = pm.newQuery(query);
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute();
      fail("expected JDOUserException->UnsupportedDatastoreFeatureException for query <" + query + ">");
    } catch (JDOUserException jdoe) {
        if (jdoe.getCause() instanceof DatastoreQuery.UnsupportedDatastoreFeatureException) {
View Full Code Here

    ds.put(null, newFlightEntity("1", "yam", null, 1, 2));

    // This is impossible in the datastore, so run totally in-memory
    String query = "SELECT FROM " + Flight.class.getName() + " WHERE origin == 'yar' || dest == null";
    Query q = pm.newQuery(query);
    q.addExtension("datanucleus.query.evaluateInMemory", "true");
    try {
      List<Flight> results = (List<Flight>) q.execute();
      Assert.assertEquals("Number of results was wrong", 2, results.size());
    } catch (JDOException jdoe) {
      fail("Threw exception when evaluating query in-memory, but should have run");
View Full Code Here

    QueryResultsCache cache = null;
    try {
      String query = "SELECT FROM " + Flight.class.getName();
      Query q = pm.newQuery(query);
      q.addExtension("datanucleus.query.results.cached", "true");
      try {
        List<Flight> results = (List<Flight>) q.execute();
        Assert.assertEquals("Number of results was wrong", 2, results.size());
      } catch (JDOException jdoe) {
        fail("Threw exception when evaluating query and caching results : " + jdoe.getMessage());
View Full Code Here

    ds.put(null, hasAncestorEntity);

    Query q = pm.newQuery(
        "select from " + HasStringAncestorStringPkJDO.class.getName()
            + " where ancestorId > ancId parameters String ancId");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute(KeyFactory.keyToString(flightEntity.getKey()));
      fail ("expected udfe");
    } catch (JDOUserException jdoe) {
        if (jdoe.getCause() instanceof DatastoreQuery.UnsupportedDatastoreFeatureException) {
View Full Code Here

    ds.put(null, hasAncestorEntity);

    Query q = pm.newQuery(
        "select from " + HasStringAncestorStringPkJDO.class.getName()
            + " where ancestorId == ancId parameters String ancId order by ancestorId ASC");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute(KeyFactory.keyToString(flightEntity.getKey()));
      fail ("expected udfe");
    } catch (JDOUserException jdoe) {
        if (jdoe.getCause() instanceof DatastoreQuery.UnsupportedDatastoreFeatureException) {
View Full Code Here

    ds.put(null, flightEntity);

    Query q = pm.newQuery(
        "select from " + HasOneToOneJDO.class.getName()
        + " where flight == f parameters " + Flight.class.getName() + " f");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute(null);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
      // good
View Full Code Here

    Entity e3 = Flight.newFlightEntity("name3", "bos3", "mia2", 27, 28);
    ds.put(null, Arrays.asList(e, e2, e3));

    try {
      Query q = pm.newQuery("select from " + Flight.class.getName() + " where name.contains(:param)");
      q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
      q.execute("na");
      fail("Should have thrown an exception when invoking 'contains' on a String");
    } catch (JDOUserException ue) {
      // Expected
    }
View Full Code Here

  public void testIsNullChild() {
    Entity e = new Entity(HasOneToOneJDO.class.getSimpleName());
    ds.put(null, e);
    Query q = pm.newQuery("select from " + HasOneToOneJDO.class.getName() + " where flight == null");
    q.addExtension(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
      q.execute();
      fail("expected");
    } catch (JDOFatalUserException ex) {
      // good
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.