Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring数据Neo4j如何聚合_Neo4j_Spring Data_Spring Data Neo4j_Spring Hateoas - Fatal编程技术网

Spring数据Neo4j如何聚合

Spring数据Neo4j如何聚合,neo4j,spring-data,spring-data-neo4j,spring-hateoas,Neo4j,Spring Data,Spring Data Neo4j,Spring Hateoas,我正在努力做我认为应该是一项非常基本的任务,但我正在努力。我的代码如下: @Query("match (x:Package) where x.houseAirwayBill = {self}.houseAirwayBill return count(x)") @JsonIgnore Long pieces @JsonProperty("total_pieces") Long getPieces(){ return pieces } 然而,它只是抛出一个堆栈strace,表示当它想要得

我正在努力做我认为应该是一项非常基本的任务,但我正在努力。我的代码如下:

@Query("match (x:Package) where x.houseAirwayBill = {self}.houseAirwayBill return count(x)")
@JsonIgnore
Long pieces

@JsonProperty("total_pieces")
Long getPieces(){
    return pieces
}
然而,它只是抛出一个堆栈strace,表示当它想要得到一张地图时,它得到了一个“1”。。。我一直在寻找其他方法来实现这一点,但我也无法让存储库在域对象中自动连接。。。我不知所措。是否没有人预测您希望在域对象中进行聚合

我的身材,格雷德尔

buildscript {
repositories {
    maven { url "https://repo.spring.io/libs-release" }
    mavenLocal()
    mavenCentral()
}
dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
     }
   }

   apply plugin: "groovy"
   apply plugin: 'spring-boot'

   sourceCompatibility = JavaVersion.VERSION_1_8
   targetCompatibility = JavaVersion.VERSION_1_8

   version  = "1.4.38"

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url "http://m2.neo4j.org/content/repositories/releases/"}
    maven { url "https://repo.spring.io/libs-release" }
    maven { url "https://repo.spring.io/libs-milestone" }
    maven { url 'http://repo.spring.io/snapshot' }
}

defaultTasks "clean", "processResources", "build"

dependencies {
    //groovy
    compile 'org.codehaus.groovy:groovy-all:2.4.0-rc-2'
//spring
compile("org.springframework.boot:spring-boot-starter-web"){
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compile("org.springframework.boot:spring-boot-starter-jetty")
compile 'org.eclipse.jetty:jetty-servlet:9.3.0.M1'
compile 'org.springframework.boot:spring-boot-actuator:1.2.3.RELEASE'
//compile 'org.springframework.data:spring-data-rest-webmvc:2.3.0.RELEASE'
//compile 'org.springframework.hateoas:spring-hateoas:0.17.0.RELEASE'
compile('org.springframework.boot:spring-boot-starter-data-rest:1.2.3.RELEASE')
//compile 'org.springframework.data:spring-data-neo4j:3.3.0.RELEASE'
compile 'org.springframework.data:spring-data-neo4j-aspects:3.3.0.RELEASE'
//compile "org.neo4j:neo4j-rest-graphdb:2.0.1"
compile("org.hibernate:hibernate-validator")
compile 'javax.persistence:persistence-api:1.0.2'
compile 'org.springframework.data:spring-data-neo4j-rest:3.4.0.BUILD-SNAPSHOT'
compile 'org.springframework.data:spring-data-jpa:1.8.0.RELEASE'

//Jersey
compile 'org.glassfish.jersey.core:jersey-client:2.17'

//JsonSchema stuff
// Required if generating equals, hashCode, or toString methods
compile 'commons-lang:commons-lang:2.6'
// Required if generating JSR-303 annotations
compile 'javax.validation:validation-api:1.1.0.CR2'
// Required if generating Jackson 2 annotations
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.0'
// Required if generating JodaTime data types
compile 'joda-time:joda-time:2.2'

//Retrofit
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.retrofit:converter-jackson:1.2.2'


//logging
compile 'ch.qos.logback:logback-classic:1.1.2'
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.2.1'
}

processResources {
    expand(project.properties)
}

因此,在仔细研究了问题并查看了文档之后,我做了以下工作:

    @Query("start item=node({self}) match (x:Package) where x.houseAirwayBill= item.houseAirwayBill return count(x)")
    @JsonIgnore
    def pieces

    @JsonProperty("total_pieces")
    @Transactional
     Long getPieces(){
        return pieces.get("count(x)") as Long
    }
start item=node({self})
非常重要,因为它将自引用绑定到一个参数,在本例中,我将该参数称为item。getter也需要在事务中。我希望这能有所帮助,因为我在任何地方都找不到一个具体的例子来说明如何做到这一点


代码使用groovy btw。这真的不可能吗?