Let's say I have this entity (for Hibernate):
@Entity
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@CollectionOfElements
@IndexColumn("phones_index")
Set<String> phones;
}
For example, I want to get instances of Person where their phones contain "555-1234". How can I do a query on this? I am looking for something similar to:
session.createCriteria(Person.class)./*something*/.add(Restrictions./*something*/"555-1234").list();
Hi you can try this one
String phone = "555-1234";
Person person= (Person) session.createQuery("from Person p join p.phones pl where pl = :phone").setString("phone", phone).uniqueResult();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With