Hi, I am a Hibernate noob and I am facing the following problem I could not solve by searching the forum:
Class C (see below) has a Set<String> S member. Let X be a String. Now I want to get all instances of C from the database, where C.S contains X.
Is there a way to get it via the Criteria, Restrictions, or Example classes. How?
Thanks for help, and sorry if this question is too easy or would have been answered by more intensive searching the forum...
Code:
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
@Entity
public class SetContainingClass {
private Long id;
private Set<String> set;
public SetContainingClass() {
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@CollectionOfElements
public Set<String> getSet() {
return set;
}
public void setSet(Set<String> set) {
this.set = set;
}
}