0

I'm having problems on querying some entity that matches some criteria (key/value - coming from the web) with it's HashMap.

The entity looks like this:

@Entity
class Entity {
   @ElementCollection
   @MapKeyColumn(name = "context_key")
   @Column(name = "context_value")
   @CollectionTable(name = "entity_context_data", joinColumns = @JoinColumn(name = "entity_id"))
   private Map<String, String> contextData = new HashMap<>();
}

I'm trying to query the Entity using Criteria:

 Criteria criteria = getSession().createCriteria(Entity.class, "entity")

for (Entry<String, String> entry : keyValuesFromWeb.entrySet()) {
   criteria.add(in(entry.getKey(), Arrays.asList(entry.getValue())));
}

But this clearly doesn't work. According to https://hibernate.atlassian.net/browse/HHH-6103 it should be solved. Anybody who got this working?

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
user2054927
  • 969
  • 1
  • 12
  • 30

0 Answers0