jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Waschkowski" <mwaschkow...@gmail.com>
Subject Re: 3.1.3.1 Removing Items
Date Mon, 23 Jul 2007 18:17:30 GMT
I said:
"However, I do see removal of the property itself as a side effect of
setting the property to null."

Thomas said:
"Removing the property by setting it to null is not a 'side effect'. It is
the only effect."
Julian said:
"No, it's the only effect."

Um, no, there are two things going on. Lets say that a property exists that
is called "firstName" and has a string value of "Joe". If you set the value
to "Jack" you have change the string value and done one thing. If you set
the value to null, well, you have done two things:
1) The string value doesn't exist
2) The property doesn't exist either!

Please see the below example code:

    Node root = session.getRootNode();
    root.setProperty("firstName", "joe");
    Property firstNamePropertyJoe = root.getProperty("firstName");
    System.out.println(firstNamePropertyJoe.getString());

    root.setProperty("firstName", "jack");
    Property firstNamePropertyJack = root.getProperty("firstName");
    System.out.println(firstNamePropertyJack.getString());

    root.setProperty("firstName", (String)null);
    session.save();
    Property propertyNull = root.getProperty("firstName");
    System.out.println(propertyNull);

You will never actually see the last system.out work because a path not
found exception will occur, because the node DOES NOT exist. Two things are
occuring!

Regards,

Mark

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message