Announcement Announcement Module
Collapse
No announcement yet.
Understanding generated queris for repositories. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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, 03:24 AM.

      Comment


      • #4
        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.

        Comment

        Working...
        X