Question

Spring Data JPA constructs a number of queries based on naming convention of the interface methods. Is there any naming convention to do a "MEMBER OF" query?

I can get the following to work with JPQL:

@Query("select e from MyEntity e where ?1 member of e.entities")

However, I'd like to use a name convention method if possible. I couldn't find anything in the docs about it, so I'm hoping I'm just missing something. If there's some fundamental reason there can't be methods for this, I'd be interested to know that too.

Was it helpful?

Solution

Skimming the latest version of this document it doesn't look like there is. Here are the available method name keywords:

http://docs.spring.io/spring-data/jpa/docs/1.6.0.RELEASE/reference/html/jpa.repositories.html#d0e1599

OTHER TIPS

I seems that the documentation is incomplete about the Containing (IsContaining, Contains) key word.

https://dzone.com/refcardz/core-spring-data extends the documentation as follows:

CONTAINING: Containing, IsContaining, Contains (String or collection types only)

So you are able to use the Containing key word as a replacement for member of.

For example:

// select e from MyEntity e where ?1 member of e.entities
findByEntitiesContaining(TypeOfMember member);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top