getOrCreate for java-rest-api neo4j fails

2013-05-22T06:51:40

I have a simple relationship test that I am trying to run to create a unique node using Rest API (java-rest-binding) https://github.com/neo4j/java-rest-binding but unfortunately I am stuck on something, here are the details: (the non-unique node and relationship works perfectly fine, its with this that it doesn't, most likely I am doing something naive (pardon my lack on knowledge of neo4j).

final UserModel userModel = new UserModel();
        final HashMap<String, Object> uModelAttributes = new HashMap<String, Object>(0);
        uModelAttributes.put("name", "AnirudhVyas");
        userModel.setAttributes(uModelAttributes);
        final HashSet<Action> buyHistory = new HashSet<Action>();
        final Action buyAction = new Action();
        final ProductModel productModel = new ProductModel();
        final HashMap<String, Object> attributes = new HashMap<String, Object>(0);
        attributes.put("name", "mercedes benz ");
        attributes.put("make", "mercedes benz");
        attributes.put("model", "sls 550");
        attributes.put("year", "2014");
        productModel.setAttributes(attributes);
        buyAction.setProduct(productModel);
        buyHistory.add(buyAction);
        userModel.setBuyHistory(buyHistory);
        System.out.println("Before");
        new UserModelDAO().createCompleteTree(userModel);
        System.out.println("Completed >>>

if i use this on the dao:

final RestNode root = api.getOrCreateNode(api.index().forNodes("users", MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext")), "name", m
                    .getAttributes().get("name"), m.getAttributes());

api.getOrCreateNode(api.index().forNodes("products", MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext")), "name", buyAction.getProduct().getAttributes().get("name"), buyAction.getProduct().getAttributes()), RelationshipTypes.BOUGHT);

This basically Fails with:

   java.lang.RuntimeException: Error retrieving or creating node for key name and value AnirudhVyas with index users
        at org.neo4j.rest.graphdb.ExecutingRestAPI.getOrCreateNode(ExecutingRestAPI.java:448)
        at org.neo4j.rest.graphdb.RestAPIFacade.getOrCreateNode(RestAPIFacade.java:223)
        at xxxx.xxxx.xxxx.graph.UserModelCreateTasteKeyNeo4JBatchCallback.recordBatch(UserModelCreateTasteKeyNeo4JBatchCallback.java:61)

Copyright License:
Author:「anirudh.vyas」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/16680802/getorcreate-for-java-rest-api-neo4j-fails

About “getOrCreate for java-rest-api neo4j fails” questions

I have a simple relationship test that I am trying to run to create a unique node using Rest API (java-rest-binding) https://github.com/neo4j/java-rest-binding but unfortunately I am stuck on somet...
In a java application using embedded Neo4j (1.8.3) I have subclassed org.neo4j.graphdb.index.UniqueFactory.UniqueNodeFactory and have this method in it: @Override public Node
Working with SDN 2.1.0.BUILD-SNAPSHOT Is there a Domain-level, threadsafe way of executing a getOrCreate? I have @NodeEntity public class ResourceEntity extends Entity { @Fetch @Indexed(uniqu...
I am using spark 2.1 with scala 2.11 and spark-sql_2.11 in intelliJ. When I am using getOrCreate() method with SparkSession I am getting an error. When I am commenting getOrCreate() code is runnin...
I'm making a web app with ASP.NET MVC and Angular. To cache results for the main dashboard I'm using the inbuilt IMemoryCache. I'm using GetorCreate for its Async version, but what's the real diff...
What is the purpose of the getOrCreate method from SparkContext class? I don't understand when we should use this method. If I have 2 spark applications that are run with spark-submit, and in the ...
I'm trying to write a sample program in Scala/Spark/H2O. The program compiles, but throws an exception in H2OContext.getOrCreate: object App1 extends App{ val conf = new SparkConf() ...
I found out that the default way of using EncryptedSharedPreferences is to create the key with MasterKeys for it. However, when I replace val masterKeyAlias = MasterKeys.getOrCreate() with a sample
We are running Spark 2.1.0 in Scala in a cluster. We invoke jobs through the REST API, here is a sample Java command line generated by that client and invoked: "/usr/lib/jvm/jre-1.7.0/bin/java" "...
i try to create a custom getOrCreate method using find and if nothing is returned using create my class : class User include Neo4j::ActiveNode include Neo4jrbConcern property :name prope...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.