コード例 #1
0
  public void testPolyQuery() throws Exception {
    CompassSession session = openSession();
    CompassTransaction tr = session.beginTransaction();

    Long id = new Long(1);
    ExtendsA extendsA = new ExtendsA();
    extendsA.setId(id);
    extendsA.setValue("value");
    extendsA.setExtendsValue("evalue");

    session.save("extends", extendsA);

    extendsA = (ExtendsA) session.load("extends", id);
    assertEquals("value", extendsA.getValue());

    id = new Long(1);
    extendsA = new ExtendsA();
    extendsA.setId(id);
    extendsA.setValue("value");
    extendsA.setExtendsValue("evalue");

    session.save("override", extendsA);

    extendsA = (ExtendsA) session.load("override", id);
    assertEquals("value", extendsA.getValue());

    CompassHits hits = session.queryBuilder().polyAlias("base").hits();
    assertEquals(2, hits.length());

    hits = session.find("base");
    assertEquals(2, hits.length());

    tr.commit();
    session.close();
  }
コード例 #2
0
  public void testSimpleExtends() throws Exception {
    CompassSession session = openSession();
    CompassTransaction tr = session.beginTransaction();

    Long id = new Long(1);
    ExtendsA extendsA = new ExtendsA();
    extendsA.setId(id);
    extendsA.setValue("value");
    extendsA.setExtendsValue("evalue");

    session.save("extends", extendsA);

    extendsA = (ExtendsA) session.load("extends", id);
    assertEquals("value", extendsA.getValue());

    tr.commit();
    session.close();
  }
コード例 #3
0
  public void testSimpleExtendsWithNoOverride() throws Exception {
    CompassSession session = openSession();
    CompassTransaction tr = session.beginTransaction();

    Long id = new Long(1);
    ExtendsA extendsA = new ExtendsA();
    extendsA.setId(id);
    extendsA.setValue("value");
    extendsA.setExtendsValue("evalue");

    session.save("override1", extendsA);

    extendsA = (ExtendsA) session.load("override1", id);
    assertEquals("value", extendsA.getValue());

    Resource r = session.loadResource("override1", id);
    assertNotNull(r.getProperty("mvalue"));
    assertNotNull(r.getProperty("mvalue1"));

    tr.commit();
    session.close();
  }