Spring Data JPA: Query for Field in List of Objects -
i'm looking correct method name find document
s given target
's type
:
public class document { @indexed(name = "targets") private list<target> targets; public class target { private string value; private string type; } }
unfortunately, of following method names aren't working:
list<document> findbytargettype(...); list<document> findbytargetstargettype(...); list<document> findbytargetscontainstargettype(...); list<document> findbytargetscontainstargettargettype(...); list<document> findbytargetscontainingtargettype(...); list<document> findbytargetscontainingtargettargettype(...);
so correct method name accomplish desired feature?
you can try below query.
using @query
annotation
@query("{ 'targets.type' : ?0 }") list<document> findbytargetstype(string type);
or
using repository supported keywords
list<document> findbytargetstype(string type);
Comments
Post a Comment