没有对象被ID读取

时间:2018-10-13 13:22:51

标签: java neo4j

我正在尝试使用Neo4j OGM通过id读取对象

我这样做

var session = require(SessionFactory.class).openSession();
long value = req.param("id").longValue();
return session.load(Movie.class, value);

根据日志,查询看起来像这样

Request: MATCH (n:`Movie`) WHERE ID(n) = { id } WITH n RETURN n,[ [ (n)<-[r_a1:`ACTED_IN`]-(p1:`Person`) | [ r_a1, p1 ] ] ] with params {id=1}

电影课看起来像这样

@NodeEntity
public class Movie {

    @Id
    @GeneratedValue
    private Long id;
    private String title;
    private int released;
    private String tagline;

    @JsonIgnoreProperties("movie")
    @Relationship(type = "ACTED_IN", direction = Relationship.INCOMING)
    private List<Role> roles;

    public Movie() {
    }

    public Movie(String title, int released, String tagline) {
        this.title = title;
        this.released = released;
        this.tagline = tagline;
    }
    ...

我这样实例化会话工厂

var configuration = new Configuration.Builder()
    .uri(conf.getString("db.url"))
    .credentials(conf.getString("db.user"), conf.getString("db.password"))
    .build();
var sessionFactory = new SessionFactory(configuration,
    "com.project.domain");

我可以像这样返回所有对象

var session = require(SessionFactory.class).openSession();
return session.loadAll(Movie.class);

当我使用WHERE ID(n) = 1在浏览器中执行查询时,它也可以正常工作。

出什么问题了?

0 个答案:

没有答案