Wolfgang-Schuetzelhofer / jcypher

Java access to Neo4J graph databases at multiple levels of abstraction
Apache License 2.0
86 stars 15 forks source link

question concerning property types #23

Closed mpetris closed 8 years ago

mpetris commented 8 years ago

Hi Wolfgang,

thanks for the good work!

I have a question about the type mapping of JCypher. I encounter the issue that I store primitive long values in a node property and get back BigDecimals. Is there a way to influence that? I would like to get long or at least java.lang.Long back. And btw is there an example for queryResult.resultOf(new JcPath("mypath")); I couldn't find anything in the documentation or the samples.

Best, Marco

Wolfgang-Schuetzelhofer commented 8 years ago

Hi Marco, Neo4j does not store the concrete type of a numeric property value and hence returns a BigDecimal. Therefore JCypher also returns a BigDecimal in case of a numeric property value. But you can call longValue(), intValue(), shortValue(), ... on the BigDecimal to retrieve the wanted type.

A simple expression using JcPath:

JcPath p = new JcPath("p"); JcRelation x = new JcRelation("x");

IClause[] clauses = new IClause[]{

MATCH.path(p).node().label("Member").relation().out().type("PLAYED") .node().label("Song"),

RETURN.value(p.nodes()), RETURN.value(p.relations()) };

You can find more examples of expressions using JcPath in the test package of JCypher (you need to checkout or clone the project). You can then look for uses of JcPath in the test package.

I hope that helps. I am out of office for the next week, but I will be here for further questions and discussions in the week thereafter.

Best regards, Wolfgang

mpetris commented 8 years ago

Hi Wolfgang,

thanks! Very helpful.

Best, Marco

Am 17.06.2016 um 16:18 schrieb Wolfgang Schuetzelhofer:

Hi Marco, Neo4j does not store the concrete type of a numeric property value and hence returns a BigDecimal. Therefore JCypher also returns a BigDecimal in case of a numeric property value. But you can call longValue(), intValue(), shortValue(), ... on the BigDecimal to retrieve the wanted type.

A simple expression using JcPath:

JcPath p = new JcPath("p"); JcRelation x = new JcRelation("x");

IClause[] clauses = new IClause[]{

MATCH.path(p).node().label("Member").relation().out().type("PLAYED") .node().label("Song"),

RETURN.value(p.nodes()), RETURN.value(p.relations()) };

You can find more examples of expressions using JcPath in the test package of JCypher (you need to checkout or clone the project). You can then look for uses of JcPath in the test package.

I hope that helps. I am out of office for the next week, but I will be here for further questions and discussions in the week thereafter.

Best regards, Wolfgang

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Wolfgang-Schuetzelhofer/jcypher/issues/23#issuecomment-226781007, or mute the thread https://github.com/notifications/unsubscribe/ABD3v43MhGtHRWljcV_Vkr36sW1JnZnQks5qMqyfgaJpZM4I2ufD.