I am trying to model my objects in a way that would work both with hibernate JPA and GAE JPA.
I have a class Item
that has a list of properties. I need to find all the items with specific properties. For example:
@Entity
public class Item {
@Id
public Long id;
@ManyToMany(name="properties")
public List<Property> props;
}
@Entity
public class Property {
@Id
public Long id;
public String value;
}
and my query would be like
select i from Item i join i.props p where p.id=1 and p.id=3 and p.id=10
in which 1, 3, and 10 are the ids of the properties I am looking for. For example I can have book items and look for these properties: Property(1, "category:book") Property(3, "text:anatomy"), Property(10, "text:brain"). You can think of the properties as tags for Items.
JAE JPA doesn't support ManyToMany relationship. Any suggestion how to model this?
Thank you in advance.