neo4j - Spring Data @Query on fields -


the @query on property retrieves values if retrieve entity db.

@nodeentity public class team {     @graphid     private long nodeid;      @relatedto (type = "previously_known_as")     private team previouslyknownas;      @query ("start t=node({self}) match t-[:previously_known_as]-other return other")         private iterable<team> aliases; } 

the below test works if uncomment line read explicitly db. why necessary? see query being run after save(t) alias field null if doesn't read db uncommenting line

@test public void alias() {     team t = new team();     t.setname("alpharetta one");      team prev = new team();     prev.setname("previous name");     teamrepo.save(prev);      t.setpreviouslyknownas(prev);     teamrepo.save(t);      //t = teamrepo.findone(t.getnodeid());//only works if uncomment     assertnotnull(t.getaliases()); } 

try

 t=teamrepo.save(t); 

i dont think save operation update pojo give it, while returned object should managed enttiy. key lies in reference documentation

the @query annotation leverages delegation infrastructure supported spring data neo4j.it provides dynamic fields which, when accessed, return values selected provided query language expression.

since dynamic field, value isnt instanciated instead fetched db every time method called. this, proxy object has used. there no way sdn change t object reference proxy object, , thats why not working, if not using entity returned save().


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -