Fast Object Database for Java - with JPA/JDO support

How to pass a list in query for a list field of entity.


I have a entity as bellow :-


@Table(name = "agent")
public class Agent implements Serializable
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long Id;

    private List<SocialMedia> SocialMedias;

    public Agent()

    public Long getId()
        return Id;

    public List<SocialMedia> getSocialMedias()
        return SocialMedias;

    public void setSocialMedias(List<SocialMedia> SocialMedias)
        this.SocialMedias = SocialMedias;
    public enum SocialMedia
        Facebook, Twitter, Instagram, Whatsapp

I need all the agents who have active in Facebook and Twitter. what should be the query?



I have used "IN" and "Member of" but not working.

code sample :-

    ArrayList<Agent.SocialMedia> soList = new ArrayList<>();
    Query qry = m.em.createQuery(
      "Select a from Agent a where a.SocialMedias in (:so)");
    qry.setParameter("so", soList);
    List<Agent> ents = qry.getResultList();

You may try:

SELECT a from Agent a JOIN a.SocialMedias m where m in :so
ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Thank you Its working.

Post Reply