Package org.apache.ojb.broker

Examples of org.apache.ojb.broker.Person


                    metadata classes are cached
                    */
                    Project project = new Project();
                    project.setTitle(title);

                    Person p1 = new Person();
                    p1.setFirstname(title);
                    List l1 = new ArrayList();
                    l1.add(project);
                    p1.setProjects(l1);

                    Person p2 = new Person();
                    p2.setFirstname(title);
                    List l2 = new ArrayList();
                    l2.add(project);
                    p2.setProjects(l2);

                    Role r1 = new Role();
                    r1.setPerson(p1);
                    r1.setRoleName(title);
                    r1.setProject(project);
                    List roles1 = new ArrayList();
                    roles1.add(r1);

                    Role r2 = new Role();
                    r2.setPerson(p2);
                    r2.setRoleName(title);
                    r2.setProject(project);
                    List roles2 = new ArrayList();
                    roles2.add(r2);

                    p1.setRoles(roles1);
                    p2.setRoles(roles2);

                    Object obj = ClassHelper.newInstance(targetTestClass);

                    broker.beginTransaction();
                    broker.store(obj);
View Full Code Here


  public void testPersonEmptyProjectsInsert()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    Person pers = new Person();
    myPB.store(pers);
    //SELECT A0.VERSION,A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  'SEQ_PERSON' ) AND A0.FIELDNAME LIKE  'ID'
    //SELECT VERSION,GRAB_SIZE,MAX_KEY,FIELDNAME,TABLENAME FROM OJB_HL_SEQ WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'
    //UPDATE OJB_HL_SEQ SET MAX_KEY='150',GRAB_SIZE='20',VERSION='7' WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'  AND VERSION = '6'
    // commit|
    //SELECT LASTNAME,FIRSTNAME,ID FROM PERSON WHERE ID = '131'
    //INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('131','','')
    logStmtCount("Storing first person")// 6. oma: why so many? double lookup in OJB_HL_SEQ !
    resetStmtCount();
    pers = new Person();
    myPB.store(pers, ObjectModification.INSERT);
    myPB.commitTransaction();
    // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('172','','')
    // commit
    assertStmtCount("insert second Person with empty collection.", 2);
View Full Code Here

  public void testPersonSingleProjectInsert()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    Person pers = new Person();
    pers.setFirstname("testPersonSingleProjectInsert(1)");
    Project proj = new Project();
    proj.setTitle("testPersonSingleProjectInsert(1)");
    myPB.store(pers);
    myPB.store(proj);
    logStmtCount("Storing first person and first project");
    // 12. oma: why so many? double lookup in OJB_HL_SEQ !
    resetStmtCount();
    pers = new Person();
    Project proj2 = new Project();
    proj2.setTitle("proj2");
    Collection projects = Arrays.asList(new Project[] {proj2});
    pers.setProjects(projects);
    myPB.store(pers, ObjectModification.INSERT);
    myPB.commitTransaction();
    // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('292','','')
    // SELECT TITLE,DESCRIPTION,ID FROM PROJECT WHERE ID = '88'
    // INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('88','proj2','')
View Full Code Here

  public void testPersonEmptyProjectsInsert()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    Person pers = new Person();
    myPB.store(pers);
    //SELECT A0.VERSION,A0.GRAB_SIZE,A0.MAX_KEY,A0.FIELDNAME,A0.TABLENAME FROM OJB_HL_SEQ A0 WHERE (A0.TABLENAME LIKE  'SEQ_PERSON' ) AND A0.FIELDNAME LIKE  'ID'
    //SELECT VERSION,GRAB_SIZE,MAX_KEY,FIELDNAME,TABLENAME FROM OJB_HL_SEQ WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'
    //UPDATE OJB_HL_SEQ SET MAX_KEY='150',GRAB_SIZE='20',VERSION='7' WHERE TABLENAME = 'SEQ_PERSON'  AND FIELDNAME = 'ID'  AND VERSION = '6'
    // commit|
    //SELECT LASTNAME,FIRSTNAME,ID FROM PERSON WHERE ID = '131'
    //INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('131','','')
    logStmtCount("Storing first person")// 6. oma: why so many? double lookup in OJB_HL_SEQ !
    resetStmtCount();
    pers = new Person();
    myPB.store(pers, ObjectModificationDefaultImpl.INSERT);
    myPB.commitTransaction();
    // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('172','','')
    // commit
    assertStmtCount("insert second Person with empty collection.", 2);
View Full Code Here

  public void testPersonSingleProjectInsert()
  {
    resetStmtCount();
    myPB.clearCache();
    myPB.beginTransaction();
    Person pers = new Person();
    pers.setFirstname("testPersonSingleProjectInsert(1)");
    Project proj = new Project();
    proj.setTitle("testPersonSingleProjectInsert(1)");
    myPB.store(pers);
    myPB.store(proj);
    logStmtCount("Storing first person and first project");
    // 12. oma: why so many? double lookup in OJB_HL_SEQ !
    resetStmtCount();
    pers = new Person();
    Project proj2 = new Project();
    proj2.setTitle("proj2");
    Collection projects = Arrays.asList(new Project[] {proj2});
    pers.setProjects(projects);
    myPB.store(pers, ObjectModificationDefaultImpl.INSERT);
    myPB.commitTransaction();
    // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('292','','')
    // SELECT TITLE,DESCRIPTION,ID FROM PROJECT WHERE ID = '88'
    // INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('88','proj2','')
View Full Code Here

  {
    super.setUp();
    resetStmtCount();
    myPB = PersistenceBrokerFactory.defaultPersistenceBroker();
    myPB.beginTransaction();
    Person a = new Person();
    a.setFirstname("A");
    myPB.store(a);
    aId = new Identity(a, myPB);
    myPB.commitTransaction();
    logStmtCount("Wrote test data");
  }
View Full Code Here

    resetStmtCount();
    myPB.clearCache();
    logger.info("begin txn");
    myPB.beginTransaction();
    logger.info("retrieving person");
    Person a = (Person)myPB.getObjectByIdentity(aId);
    // SELECT ... FROM PERSON WHERE ID = ..
    // SELECT ... FROM PERSON_PROJECT WHERE PERSON_ID = ..
    // SELECT ... FROM PROJECT, PERSON_PROJECT WHERE ...
    logger.info("comitting txn");
    // COMMIT
View Full Code Here

  {
    resetStmtCount();
    myPB.clearCache();
    logger.info("begin txn");
    myPB.beginTransaction();
    Person a = (Person)myPB.getObjectByIdentity(aId);   // see above
    assertStmtCount("retrieve Person by Identity", 3);
    resetStmtCount();
    Person b = (Person)myPB.getObjectByIdentity(aId);   // should use cache
    assertSame(a, b);
    assertStmtCount("retrieve Person 2nd time", 0);
    myPB.commitTransaction();
  }
View Full Code Here

  {
    resetStmtCount();
    myPB.clearCache();
    logger.info("begin txn");
    myPB.beginTransaction();
    Person a = (Person)myPB.getObjectByIdentity(aId);   // see above
    assertStmtCount("retrieve Person by Identity", 3);
    resetStmtCount();
    logger.info("accessing projects");
    Collection c = a.getProjects();
    assertEquals(0, c.size());
    assertStmtCount("accessing non-proxy collection", 0);
    Collection d = a.getRoles();
    assertStmtCount("accessing proxy-collection", 0);
    assertEquals(0, d.size());
    myPB.commitTransaction();
  }
View Full Code Here

TOP

Related Classes of org.apache.ojb.broker.Person

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.