Package com.google.appengine.datanucleus.test.jpa

Examples of com.google.appengine.datanucleus.test.jpa.Book


    Entity parentEntity = new Entity(HasOneToOneJPA.class.getSimpleName());
    ds.put(parentEntity);
    Entity bookEntity = Book.newBookEntity("Joe Blow", "11111", "Bar Book", 1929);
    ds.put(bookEntity);

    Book book = new Book();
    Query q = em.createQuery(
        "select from " + HasOneToOneJPA.class.getName() + " c where book = :b");
    q.setParameter("b", book);
    q.setHint(DatastoreManager.QUERYEXT_INMEMORY_WHEN_UNSUPPORTED, "false");
    try {
View Full Code Here


    Entity e = Book.newBookEntity("max", "12345", "t1");
    ds.put(e);
    Query q = em.createQuery(
        "select from " + Book.class.getName() + " c where title = :p");
    q.setParameter("p", "t1");
    Book pojo = (Book) q.getSingleResult();
    assertEquals(e.getKey(), KeyFactory.stringToKey(pojo.getId()));
  }
View Full Code Here

  public void testNamedQuery() {
    Query q = em.createNamedQuery("namedQuery");
    assertTrue(q.getResultList().isEmpty());
    Entity e = Book.newBookEntity("author", "12345", "yam");
    ds.put(e);
    Book b = (Book) q.getSingleResult();
    assertEquals(e.getKey(), KeyFactory.stringToKey(b.getId()));
  }
View Full Code Here

    List<String> ids = (List<String>) q.getResultList();
    assertEquals(2, ids.size());
    assertEquals(KeyFactory.keyToString(e1.getKey()), ids.get(0));
    assertEquals(KeyFactory.keyToString(e2.getKey()), ids.get(1));

    Book b = em.find(Book.class, e1.getKey());
    assertEquals("author", b.getAuthor());
    b.setAuthor("not author");
    commitTxn();
    beginTxn();
    b = em.find(Book.class, e1.getKey());
    assertEquals("not author", b.getAuthor());
    commitTxn();
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    List<Object[]> results = (List<Object[]>) q.getResultList();
    assertEquals(1, results.size());
    assertEquals(2, results.get(0).length);
    assertEquals(KeyFactory.keyToString(e1.getKey()), results.get(0)[0]);
    Book b = em.find(Book.class, e2.getKey());
    assertEquals(b, results.get(0)[1]);
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    List<Object[]> results = (List<Object[]>) q.getResultList();
    assertEquals(1, results.size());
    assertEquals(2, results.get(0).length);
    assertEquals(KeyFactory.keyToString(e1.getKey()), results.get(0)[0]);
    Book b = em.find(Book.class, e2.getKey());
    List<Book> books = (List<Book>) results.get(0)[1];
    assertEquals(1, books.size());
    assertEquals(b, books.get(0));
  }
View Full Code Here

    assertTrue(q.getResultList().isEmpty());
    Query q2 = em.createQuery("select from " + Book.class.getName() + " c" + " where title <> null");
    assertTrue(q2.getResultList().isEmpty());
    e = Book.newBookEntity("auth2", "isbn2", "not null");
    ds.put(e);
    Book b = (Book) q.getSingleResult();
    assertEquals("not null", b.getTitle());
    b = (Book) q2.getSingleResult();
    assertEquals("not null", b.getTitle());
  }
View Full Code Here

    Query q = em.createQuery("select from " + Book.class.getName() + " c" + " where title <> :p");
    q.setParameter("p", null);
    assertTrue(q.getResultList().isEmpty());
    e = Book.newBookEntity("auth2", "isbn2", "not null");
    ds.put(e);
    Book b = (Book) q.getSingleResult();
    assertEquals("not null", b.getTitle());
  }
View Full Code Here

    ds.put(e);
    Query q = em.createQuery("select from " + Book.class.getName() + " c" + " where title <> 'yar'");
    assertTrue(q.getResultList().isEmpty());
    e = Book.newBookEntity("auth2", "isbn2", "not yar");
    ds.put(e);
    Book b = (Book) q.getSingleResult();
    assertEquals("not yar", b.getTitle());
  }
View Full Code Here

    Query q = em.createQuery("select from " + Book.class.getName() + " c" + " where title <> :p");
    q.setParameter("p", "yar");
    assertTrue(q.getResultList().isEmpty());
    e = Book.newBookEntity("auth2", "isbn2", "not yar");
    ds.put(e);
    Book b = (Book) q.getSingleResult();
    assertEquals("not yar", b.getTitle());
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.Book

Copyright © 2018 www.massapicom. 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.