[hibernate-dev] document update change?

Sanne Grinovero sanne at hibernate.org
Wed Apr 1 06:07:58 EDT 2015


Hi Ales,
I expect our Update routines to still work. I don't know what the code
you're showing does though, as those are not our APIs.

If you could share a test using our APIs I'll look at it.

The only thing I can think of is that now there's an explicit FLUSH
type of Work, if you miss that you might hit stale (deleted) values
with a Query.. but this mistake should only be possible if you're
driving the backend directly as our public APIs generate them as
needed.

Thanks,
Sanne

On 1 April 2015 at 10:59, Ales Justin <ales.justin at gmail.com> wrote:
> 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
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev


More information about the hibernate-dev mailing list