Results 1 to 4 of 4

Thread: Understanding generated queris for repositories.

  1. #1
    Join Date
    Jun 2012
    Posts
    18

    Default Understanding generated queris for repositories.

    I have a repository interface defined as:
    Code:
    package com.eml.repository;
    public interface AssetRepository extends GraphRepository<Asset>
    It has a method defined:
    Code:
    	com.eml.domain.Asset getAssetByHash(String hash);
    This works. I am trying to understnad the query that this actually generates, so that I can create a modifed query. I thought it should be:
    Code:
    	@Query(
    			"START asset=node:Asset(hash={0}) " +
    			" RETURN asset "
    			)
    	com.eml.domain.Asset getAssetByHash(String hash);
    but this returns nothing.
    I'm not sure why it returns nothing.

    Turning on debug logging for a test run, I see the default query is:
    Code:
    DEBUG CypherQueryEngine - Executing cypher query: START `asset`=node:`nodes`(`hash`={0}) RETURN `asset` params {0=9df01adca030c4eb0c27fc7bb0b1a4a8a26b48538a2d1b5dcc9a6ae4e05b3095}
    which makes even less sense to me.

    Any help appreciated.

  2. #2
    Join Date
    Jun 2012
    Posts
    18

    Default

    I should clarify that the autogenerated query makes no sense as it looks like it would find any node of any type with an attribte named hash whos value matched that provided.

  3. #3
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    What does your domain object look like? Which version of SDN are you using? Your assumption is right, the query should look like that, except if you annotated your field with

    Code:
    @Indexed(indexType=IndexType.GLOBAL)
    Last edited by MichaelHunger; Oct 5th, 2012 at 02:24 AM.

  4. #4
    Join Date
    Jun 2012
    Posts
    18

    Default

    Yes, I had used that index do to a defect in Neo4j (that was reciently fixed). I hadn't relized that was what GLOBAL meant. Changing in to INSTANCE, the query now works.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •