Database Reference
In-Depth Information
er SDN comes across a method defined in a repository interface that doesn't have an expli-
cit @Query annotation, it will try to dynamically construct a Cypher query for you, based
on the name of your method. SDN will break down the method name into parts that are
matched against the metamodel. All of these parts map to properties defined on the associ-
ated domain entity class.
There are quite a few options and permutations available, including specifying sort order,
specifying range queries, requesting distinct results, and much more. We can't cover them
all, but the core set of rules used to recognize dynamic methods can be summarized as fol-
lows:
• Any method starting with zero or one of find , read , get
• Optionally followed by any alphanumeric combination of characters
• Subsequently followed by the term By (uppercase B)
• Subsequently followed by one or more names of any properties on the associated
domain entity, with the first character of the property as uppercase, and multiple
propertiesseparatedbytheterm And orothercomparisonseparatorslike Great-
erThan or Like
To demonstrate some of these rules in action, we've defined a few methods that all aim to
find any users with a particular name (for example, find all “Susan”s). Have a look at list-
ing 9.14 and notice how all of the method definitions on the UserRepository interface
will ultimately result in exactly the same underlying Cypher query being generated. Note
also that as with annotated queries, the parameter arguments relate to aspects of the meth-
od, in this case, the parts representing the property names.
Listing 9.14. Dynamically generated query methods
 
Search WWH ::




Custom Search