I have this Users class
Code:
@Entity
@Table(name = "Users")
public class Users implements Serializable {
private static final long serialVersionUID = -5638228567536191397L;
@Id
@Column(name = "_id")
private ObjectId _id;
private String name;
@ElementCollection
private List<String> mail;
//getter, setter ...
}
following is a json from
mongodb Users collection. where mail is a field of string array
Code:
{
"_id" : ObjectId("55c59b30a5c2073240ffc274"),
"name" : "john doe"
"mail" : ["abc@blah.com"]
}
I want a very simple query which finds a user whose mail is 'abc@blah.com'Following query returns me a null result, I'm not sure what I'm missing here.
Code:
TypedQuery<Users> query = em.createQuery("SELECT u FROM Users u JOIN u.mail m WHERE m ='abc@blah.com' ", Users.class)
List<Users> users = query.getResultList();
I also tried with adding another embedded object but same result
helpful links:
http://in.relation.to/2015/03/17/hibernate-ogm-times-2413-and-42-beta-1-released/#H-QueryImprovements
http://antoniogoncalves.org/2009/11/01/mapping-and-querying-a-list-of-primitive-types-with-jpa-2-0
Any help would be appreciated
Thanks