I have a strange issue with alibaba objects, were if two instances of an
object are open, a setProperty() on one of them will result in
getProperty() of the other one returning the changed value, but not
getProperty() of the object on which setProperty() was called. I would
like to know if this is expected behaviour, or if it is bug.
Reproducable testcase:
@Test
@Transactional
public void createThenGet1() throws Exception {
URI uri = conn().getValueFactory().createURI("u:1");
TestNode node1 =
conn().addDesignation(conn().getObjectFactory().createObject(uri),
TestNode.class);
node1.setLatitude(14.0);
node1.setLongitude(15.0);
TestNode node2 = conn().getObject(TestNode.class, uri);
node2.setLatitude(12.0);
node2.setLongitude(13.0);
Assert.assertEquals(node1, node2);
Assert.assertEquals(12.0, node2.getLatitude(), 0.0); // fails:
expected: <12.0> but was: <14.0>
}
The following testcase succeeds (reads the property from node1 instead
of node2):
@Test
@Transactional
public void createThenGet2() throws Exception {
URI uri = conn().getValueFactory().createURI("u:1");
TestNode node1 =
conn().addDesignation(conn().getObjectFactory().createObject(uri),
TestNode.class);
node1.setLatitude(14.0);
TestNode node2 = conn().getObject(TestNode.class, uri);
node2.setLatitude(12.0);
Assert.assertEquals(node1, node2);
Assert.assertEquals(12.0, node2.getLatitude(), 0.0); // succeeds
}
TestNode.class:
@iri("u:geonode")
public interface TestNode extends RDFObject {
@iri("u:lat")
Double getLatitude();
void setLatitude(Double latitude);
@iri("u:lon")
Double getLongitude();
void setLongitude(Double longitude);
}
Kind regards, GdV
|