[hibernate-dev] document update change?

Ales Justin ales.justin at gmail.com
Wed Apr 1 05:59:55 EDT 2015


Did entity updating changed in HS5 / Lucene4?
(aka Document updating)

Since this used to work for us (with HS4, Lucene3):

---
@Test
public void testProjectionQueriesHandleEntityModificationProperly() throws Exception {
    Entity e = createEntity("test", 1)
        .withProperty("prop", Arrays.asList("aaa", "bbb", "ccc"))
        .store();

    Query query = new Query("test")
        .addProjection(new PropertyProjection("prop", String.class))
        .addSort("prop");

    assertEquals(3, service.prepare(query).asList(withDefaults()).size());

    e = createEntity(e.getKey())
        .withProperty("prop", Arrays.asList("aaa", "bbb"))
        .store();

    assertEquals(2, service.prepare(query).asList(withDefaults()).size());

    service.delete(e.getKey());

    assertEquals(0, service.prepare(query).asList(withDefaults()).size());
}

---

Where we add each list/collection value under same field:

if (propertyValue instanceof Collection) {
    Collection collection = (Collection) propertyValue;
    for (Object element : collection) {
        if (PropertyUtils.isIndexedProperty(element)) {
            final Bridge inner = BridgeUtils.matchBridge(element);
            luceneOptions.addFieldToDocument(propertyName, inner.objectToString(element), document);
        }
    }

---

As it looks like the update still keeps the old values around:

java.lang.AssertionError: expected:<2> but was:<3>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at org.junit.Assert.assertEquals(Assert.java:555)
    at org.junit.Assert.assertEquals(Assert.java:542)
    at org.jboss.test.capedwarf.datastore.test.QueryOptimizationsTest.testProjectionQueriesHandleEntityModificationProperly(QueryOptimizationsTest.java:510)

---

Any way to force / fix this?

-Ales



More information about the hibernate-dev mailing list