neo4j-contrib / java-rest-binding

Java Bindings for the Neo4J Server REST API, providing an implementation of GraphDatabaseService
Other
120 stars 72 forks source link

RestNode.getProperty(...) returns String while Node.getProperty returns byte[] #8

Open Krishna-Chaitanya opened 12 years ago

Krishna-Chaitanya commented 12 years ago

We are facing issue for the below scenario.

  1. We have a requirement where we need to store java.util.Set in a graph node (where Rule is a complex business rule object). Since, node.setProperty(..., ...) doesn't allow complex objects, we have serialized the above Set and converted it to byte array and stored it as node.setProperty("rules",serialize("rules")) (2nd argument is a bytearray)

2.The above code works properly when we use EmbeddedGraphDatabase class. In this case, node.getProperty ("rules") returns us a byte array. We get the bytearray and deserialize it to retrieve our Set . (This works fine)

  1. But, when we use RestGraphDatabase class, node.getProperty("rules") returns us a String representation instead of a byte array. Is this expected ? Next, we tried to convert the String to byte array using String.getBytes() But, when we pass the bytearray to an ObjectInputStream to deserialize, we get "StreamCorruptedException: Invalid Stream Header".

We are looking for different alternatives to fix this . Need your help.