我有一个实体:
@Id
Long id
String username;
@ElementCollection
private Map<String, Boolean> emails;
我有存储库:
public interface UserRepository extends CrudRepository<User, Long>, UserDao {
User findOneByUsername(String username);
// This does not work, how do I make it?
@Query("select u from User u WHERE ? in u.emails.keySet")
User findOneByQueryForEmail
}
我可以使用哪种方法签名(和@Query注释)来实现findOneByQueryForEmail
来搜索keySet
电子邮件Map
的值?
答案 0 :(得分:0)
您可以尝试以下方法
@Query("select u from User u WHERE KEY(u.emails) in :emails")
User findOneByQueryForEmail(@Param("emails") List<String> emails)