gjrwebber / spring-data-gremlin

Spring data gremlin makes it easier to implement Graph based repositories. This module extends Spring Data to allow support for potentially any Graph database that implements the Tinkerpop Blueprints 2.x API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add @Query to Entity properties

gjrwebber opened this issue · comments

It would be nice to be able to add the @query annotation above a referenced Collection of @Entities and have it fetched when the Object is loaded from the graph.

Eg

@Entity
//@NodeEntity if using Neo4j annotations.
public class Person {

    private String firstName;
    private Location myLocation;
    //... 

    @Query("graph.V().has('firstName', @firstName)")
    private Set<Person> peopleWithSameName;


    @Query(value = "SELECT expand(in('located_at')) FROM (SELECT FROM Location WHERE [latitude,longitude,$spatial] NEAR [@myLocation.latitude,@myLocation.longitude,{\"maxDistance\":0.05f}])", nativeQuery = true)
    private Set<Person> peopleNearMe;

    // ...

}