Package nexj.core.persistence.sql

Examples of nexj.core.persistence.sql.ReadCountHook


      child.setValue("firstName", "ZachJr");
      child.setValue("lastName", "Tachoma");
      child.setValue("parent", parent);
      commit();

      ReadCountHook defaultCountHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      ReadCountHook externalCountHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("ExternalRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      String sRegularJoinAttributes = "(firstName lastName (children firstName lastName (visits reason (requests code))))";
      String sHeteroJoinAttributes = "(firstName lastName (children firstName lastName (externalVisits reason (externalRequests code))))";
      int nStartDefaultCount;
      int nStartExternalCount;

      nStartDefaultCount = defaultCountHook.getReadCount();
      nStartExternalCount = externalCountHook.getReadCount();
      checkSameResults(patientClass, sRegularJoinAttributes, sHeteroJoinAttributes, "((firstName . #f))");
      assertEquals(2, defaultCountHook.getReadCount() - nStartDefaultCount);
      assertEquals(1, externalCountHook.getReadCount() - nStartExternalCount);
   }
View Full Code Here


    * Tests that lazy loads don't cause heterogeneous joins.
    */
   public void testLazyRelationalJoiningRelational()
   {
      Metaclass clazz = getMetadata().getMetaclass("ExternalVisit");
      ReadCountHook readHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      ReadCountHook extHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("ExternalRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      InstanceArrayList list;
      Instance inst;
      int nStartReadCount = readHook.getReadCount();
      int nExtReadCount = extHook.getReadCount();

      list = (InstanceArrayList)Query.createRead(clazz,
         parse("(version startDate endDate)"),
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(6, list.getCount());
      inst = list.getInstance(0);
      assertEquals(nStartReadCount, readHook.getReadCount());
      assertEquals(nExtReadCount + 1, extHook.getReadCount());
      nExtReadCount = extHook.getReadCount();

      // This causes a lazy load of ExternalVisit, and will instantiate a lazy Patient instance
      assertEquals("Broken foot", inst.getValue("reason"));
      assertEquals(nExtReadCount + 1, extHook.getReadCount());
      assertEquals(nStartReadCount, readHook.getReadCount());
      inst = (Instance)inst.getValue("patient");
      assertEquals(nStartReadCount, readHook.getReadCount());

      // This will cause the read of Patient
      assertEquals("Sarah", inst.getValue("firstName"));
      assertEquals("Johnson", inst.getValue("lastName"));
      assertEquals(nStartReadCount + 1, readHook.getReadCount());
      assertEquals(nExtReadCount + 1, extHook.getReadCount());
   }
View Full Code Here

   }

   public void testLazyVirtualJoiningRelational() throws Exception
   {
      Metaclass virtualClass = getMetadata().getMetaclass("Animal");
      ReadCountHook readCountHook = (ReadCountHook)((SQLAdapter)getMetadata().getDataSource("DefaultRelationalDatabase").getComponent().getInstance(m_context)).getSQLHook();
      InstanceArrayList list;
      Instance inst;
      int nStartReadCount;

      nStartReadCount = readCountHook.getReadCount();
      list = (InstanceArrayList)Query.createRead(virtualClass,
         null,
         null,
         null,
         -1, 0, false, Query.SEC_NODE, m_context).read();

      assertEquals(4, list.getCount());
      assertEquals(nStartReadCount, readCountHook.getReadCount());
      inst = list.getInstance(0);
      assertEquals(nStartReadCount, readCountHook.getReadCount());
      assertEquals("Dog", inst.getValue("commonName"));
      assertEquals(nStartReadCount, readCountHook.getReadCount());
   }
View Full Code Here

TOP

Related Classes of nexj.core.persistence.sql.ReadCountHook

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.