I have a EntityManager and I search with using method find(Entity.class, primaryKey, mapProperty). The question is i set this Map?
@Entity
public class Entity{
@Id
private int id;
@ManyToOne
private Property prop;
//setter e getter method
//..
}
In a nutshell, I need to find all tuples that have a particular value for foreign key.Or is it better to use CriteriaAPI, if you like?
It is better to use Criteria API or JP QL. You are maybe misinterpreting meaning of third argument to find. It is not some map that you have in your entity. It contains “standard and vendor-specific properties and hints”, as explained for example in Javadocs. You do not set it if you do not have those to give. Then it is better to use find(entityClass, primaryKey), but as you see, it provides only possibility to query with primary key.