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
  @Ignore("alias property not supported yet")
  public void testBwoValues() throws Exception {
    CompassSession session = openSession();

    A a = new A();
    a.id = 1;
    a.value = "value";
    B b = new B();
    b.value = "bvalue";
    b.value2 = "bvalue2";
    a.b = b;
    session.save(a);

    Resource resource = session.loadResource(A.class, 1);
    assertNotNull(resource);
    assertEquals(6, resource.getProperties().length);
    assertEquals("A", resource.getAlias());
    assertEquals(3, resource.getProperties("value").length);

    a = (A) session.load(A.class, 1);
    assertEquals(1, a.id.longValue());
    assertNull(a.value);
    assertNull(a.b);

    session.close();
  }
  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();
  }
  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();
  }