Remove from ElementCollections objects using JPQL

My User entity has a basic collection as such:

 @ElementCollection private Set<String> completedQuests = Sets.newHashSet(); 

How can I remove some values ​​from this set for all / several users? What is the correct JPQL for this pseudo-course?

 DELETE FROM User.completeQuests WHERE value IN (:collectionOfValues) 

(An alternative is only Hibernate, although not preferred).

+4
source share
1 answer

If all else fails, native SQL.

 em .createNativeQuery( "DELETE FROM user_completedquests " + "WHERE completedquests IN (:daily)" ) .setParameter("daily", dailyQuests) .executeUpdate(); 

(not tested it yet)

0
source

All Articles