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

Examples of com.google.appengine.datanucleus.test.jpa.UnownedJoinsJPA.Student


* @author Max Ross <maxr@google.com>
*/
public class JPQLQueryUnownedJoinTest extends JPATestCase {

  public void testTransientMeansTransient() throws EntityNotFoundException {
    Student student = new Student();
    beginTxn();
    em.persist(student);
    commitTxn();
    Entity studentEntity = ds.get(KeyFactory.createKey(kindForClass(Student.class), student.getId()));
    assertEquals(3, studentEntity.getProperties().size());
    assertTrue(studentEntity.hasProperty("courses"));
    assertTrue(studentEntity.hasProperty("grade"));
    assertTrue(studentEntity.hasProperty("major"));
  }
View Full Code Here


  public void testJoinOnOneToMany_Simple() {
    Course course1 = newCourse("Biology");
    Course course2 = newCourse("Not Biology");
    persistInTxn(course1, course2);
    Student student = newStudent(10, course1, course2);
    beginTxn();
    em.persist(student);
    commitTxn();
    beginTxn();
    Query q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.coursesAlias c where "
        + "c.department = 'Biology' and "
        + "s.grade = 10");
   
    assertEquals(student.getId(), ((Student) q.getSingleResult()).getId());
    commitTxn();
  }
View Full Code Here

  public void testJoinOnOneToMany_LegalOrderBy() {
    Course course1 = newCourse("Biology");
    Course course2 = newCourse("Not Biology");
    persistInTxn(course1, course2);
    Student student = newStudent(10, course1, course2);
    persistInTxn(student);
    beginTxn();
    Query q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.coursesAlias c where "
        + "c.department = 'Biology' and "
        + "s.grade = 10 order by s.courses asc");
    assertEquals(student.getId(), ((Student) q.getSingleResult()).getId());
    commitTxn();
  }
View Full Code Here

    Course course3 = newCourse("Biology");
    Course course4 = newCourse("Not Biology");
    Course course5 = newCourse("Biology");
    Course course6 = newCourse("Not Biology");
    persistInTxn(course1, course2, course3, course4, course5, course6);
    Student student = newStudent(10, course1, course2);
    Student student2 = newStudent(11, course3, course4);
    Student student3 = newStudent(10, course5, course6);
    persistInTxn(student, student2, student3);
    beginTxn();
    Query q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.coursesAlias c where "
        + "c.department = 'Biology' and "
        + "s.grade = 10");
    q.setFirstResult(1);
    assertEquals(student3.getId(), ((Student) q.getSingleResult()).getId());
    q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.coursesAlias c where "
        + "c.department = 'Biology' and "
        + "s.grade = 10");
    q.setFirstResult(2);
View Full Code Here

    Course course3 = newCourse("Biology");
    Course course4 = newCourse("Not Biology");
    Course course5 = newCourse("Biology");
    Course course6 = newCourse("Not Biology");
    persistInTxn(course1, course2, course3, course4, course5, course6);
    Student student = newStudent(10, course1, course2);
    Student student2 = newStudent(11, course3, course4);
    Student student3 = newStudent(10, course5, course6);
    persistInTxn(student, student2, student3);
    beginTxn();
    Query q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.coursesAlias c where "
        + "c.department = 'Biology' and "
View Full Code Here

  public void testJoinOnOneToOne_Simple() {
    Major major1 = newMajor("Liberal Arts");
    Major major2 = newMajor("Engineering");
    persistInTxn(major1, major2);
    Student student1 = newStudent(10, major1);
    Student student2 = newStudent(10, major2);
    persistInTxn(student1, student2);
    beginTxn();
    Query q = em.createQuery(
        "select from " + Student.class.getName() + " s JOIN s.majorAlias m where "
        + "m.school = 'Liberal Arts' and "
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.UnownedJoinsJPA.Student

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.