On Nov 4, 2011 3:11 AM, "Rickard Öberg" <rickard.ob...@neotechnology.com> wrote: > > Hi, > > I've briefly started to look at how to map Cypher query results into > DTO's. I'm using the QueryDSL helper classes to do it, but instead of > putting the projection methods into the query object (as QueryDSL does > it), I have a separate Projection class for it. The reason is that I > don't want to require DSL users to have access to the execution engine, > which will obviously not be the case if you are creating queries on the > client which are to be sent to the server. > > Here's an example of what I want it to look like when used: > Projection projection = new Projection(engine); > > Iterable<Friend> friends = projection.iterable( start( node( "john", > john ) ) > .match( path().from( "john" ).out( "friend" ) > .link().out( "friend" ).to( "fof" ) ) > .returns( properties( "john.name", "fof.name" ) ), > Friend.class ); > System.out.println( friends ); > --- > So the Projection encapsulates the reference to the query execution, > which means that you don't need to have a reference to it when executing > the queries to do the projection. The "iterable" method takes a DSL > query and the Java class you want the results to be projected into. > Pretty straightforward. > > For now the code assumes that the fields in Friend is the same as the > order of the return results. This is broken, and will be fixed later to > use proper mapping, preferably with aliases in the return statement as > hints. > > What are the projection methods that you would like to see? What are > common usecases?
Supporting @java.beans.ConstructorProperties is nice because we can use immutable objects as dtos. > /Rickard > > -- > Rickard Öberg > Developer > Neo Technology > Twitter: @rickardoberg, Skype: rickardoberg > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user