This is slightly different from my previous question (for the same class) so I'll start a new topic. I have a class defined like this:
Code:
@Entity
@Table(name = "ncc_failure")
public class NccFailure
{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_STORE")
private long id;
@CollectionOfElements( fetch = FetchType.EAGER)
@JoinTable(
name = "ncc_failure_subnet_link",
joinColumns = @JoinColumn(name = "ncc_failure__id")
)
@Column( name="ip_subnet_id", nullable = false)
private final Set<String> subnetIds = new HashSet<>();
@AccessType("property")
@Lob
@Column(name = "summary")
private String summary;
@AccessType("property")
@Lob
@Column(name = "file_lines_data")
private String fileLinesData;
}
Now I have an existing framework that makes use of Criteria and Restrictions to specify conditions for SELECT (most it tries to convert English-language conditions into Criteria/Restrictions in order to fetch the right record). The question I have now is how to write Criteria/Restrictions against the
subnetIds variable, because it's a collection.
For example I want to get all the NccFailure whose subnetIds may contain an ID "12345". I would like to write a condition as:
criteria.add(org.hibernate.criterion.Restrictions.contains("subnetIds", "12345"));
Unfortunately this doesn't work, because there's no "contains" factory method for Restrictions. Is there a way I can achieve what I need?