I need to write dynamic query with various number of parameters in where clause. I want to use specification object as it supports dynamic queries.
I have following entity in my system:
@Getter
@Setter
@Entity
@Table(name = "thing")
public class ThingEntity implements Serializable {
  @Id private String id;
  private String type;
  @ElementCollection
  @JoinTable(name = "thing_metadata", joinColumns = @JoinColumn(name = "thing_id"))
  @MapKeyColumn(name = "key")
  @Column(name = "value")
  private Map<String, String> metadata;
  ...  
}
Query that I need to execute is following:
select id, type
from thing
where id not in (
                select thing_id
                from thing_metadata
                where key = 'paramName1' or key ='paramName2'
)
Can anyone help me to write query using criteria builder?
public Specification<ThingEntity> specificationByKeys() {
  return (root, query, cb) -> {
     ???
  };
}
 
    