user1147862
user1147862

Reputation: 4226

Another exception thrown by Neo4jclient

Trying to use Neo4jClient, getting this exception saying that it couldn't handle the otherwise valid response from Neo4j:

{"Neo4j returned a valid response, however Neo4jClient was unable to deserialize into the object structure you supplied.

First, try and review the exception below to work out what broke.

If it's not obvious, you can ask for help at http://stackoverflow.com/questions/tagged/neo4jclient

Include the full text of this exception, including this message, the stack trace, and all of the inner exception details.

Include the full type definition of MyStory.Logic.DbUpdateSlice.Model.DbUpdate.

Include this raw JSON, with any sensitive values replaced with non-sensitive equivalents:

{
  \"columns\" : [ \"dbUpdates\" ],
  \"data\" : [ [ {
    \"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out\",
    \"data\" : {
      \"UpdateStart\" : \"2014-10-24T15:30:23\",
      \"UpdateMethodName\" : \"abc.def\",
      \"DbUpdateState\" : \"Running\",
      \"UniqueId\" : 1
    },
    \"traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/traverse/{returnType}\",
    \"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all/{-list|&|types}\",
    \"property\" : \"http://127.255.0.0:20001/db/data/node/853098/properties/{key}\",
    \"self\" : \"http://127.255.0.0:20001/db/data/node/853098\",
    \"properties\" : \"http://127.255.0.0:20001/db/data/node/853098/properties\",
    \"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/out/{-list|&|types}\",
    \"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in\",
    \"extensions\" : {
    },
    \"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships\",
    \"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853098/paged/traverse/{returnType}{?pageSize,leaseTime}\",
    \"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/all\",
    \"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853098/relationships/in/{-list|&|types}\"
  } ], [ {
    \"outgoing_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out\",
    \"data\" : {
      \"UpdateStart\" : \"2014-11-04T01:32:23\",
      \"UpdateMethodName\" : \"xyz.123.987\",
      \"DbUpdateState\" : \"Failed\",
      \"UniqueId\" : 2
    },
    \"traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/traverse/{returnType}\",
    \"all_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all/{-list|&|types}\",
    \"property\" : \"http://127.255.0.0:20001/db/data/node/853099/properties/{key}\",
    \"self\" : \"http://127.255.0.0:20001/db/data/node/853099\",
    \"properties\" : \"http://127.255.0.0:20001/db/data/node/853099/properties\",
    \"outgoing_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/out/{-list|&|types}\",
    \"incoming_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in\",
    \"extensions\" : {
    },
    \"create_relationship\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships\",
    \"paged_traverse\" : \"http://127.255.0.0:20001/db/data/node/853099/paged/traverse/{returnType}{?pageSize,leaseTime}\",
    \"all_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/all\",
    \"incoming_typed_relationships\" : \"http://127.255.0.0:20001/db/data/node/853099/relationships/in/{-list|&|types}\"
  } ] ]
}
Parameter name: content"}

Definition of DbUpdate

public class DbUpdate
{
    public long UniqueId { get; set; }
    public string UpdateMethodName { get; set; }
    public DateTime? UpdateStart { get; set; }
    public DateTime? UpdateEnd { get; set; }
    public DbUpdateState DbUpdateState { get; set; }
}

Actual test code:

        var dbUpdate1 = new DbUpdate()
        {
            UpdateMethodName = "abc.def",
            UpdateStart = new DateTime(2014, 10, 24, 15, 30, 23),
            UpdateEnd = null,
            DbUpdateState = DbUpdateState.Running
        };

        long dbUpdate1UniqueId = dbUpdateRepository.CreateDbUpdate(dbUpdate1);

        var dbUpdates = dbUpdateRepository.GetAllDbUpdates().ToList();

<<<<< exception thrown inside this method. See below.


the repo class that contains the methods called from the test code:

public class DbUpdateRepository: IDbUpdateRepository
{
    readonly IGraphClient graphClient;
    readonly IMyStoryUserPrincipal principal;
    readonly IMyStoryUniqueIdGenerator uniqueIdGenerator;

    public DbUpdateRepository (
        IMyStoryUserPrincipal principal,
        IGraphClient graphClient,
        IMyStoryUniqueIdGenerator uniqueIdGenerator)
    {
        this.principal = principal;
        this.graphClient = graphClient;
        this.uniqueIdGenerator = uniqueIdGenerator;
    }

    public IEnumerable<DbUpdate> GetAllDbUpdates ()
    {
        var query = graphClient
            .RootNode
            .StartCypher("root")
            .Match("root-[:" + HasDbUpdates.TypeKey + "]-dbUpdates")
            .Return(dbUpdates => dbUpdates.As<DbUpdate>());

        return query.Results;      <<<<< exception thrown here
    }


    public long CreateDbUpdate (DbUpdate dbUpdate)
    {
        dbUpdate.UniqueId = uniqueIdGenerator.NextDbUpdateId();

        graphClient.Create(dbUpdate,
                            new HasDbUpdates(graphClient.RootNode)
                            {
                                Direction = RelationshipDirection.Incoming
                            });

        return dbUpdate.UniqueId;
    }
}

Upvotes: 0

Views: 326

Answers (1)

user1147862
user1147862

Reputation: 4226

Turns out that Neo4jClient cannot handle DateTime. You have to use DateTimeOffset.

Upvotes: 1

Related Questions