1

I have entity with this field:

//on main entity
@OneToMany(mappedBy="minutisPreke", targetEntity=MinutisPrekeTiekejas.class, fetch=FetchType.EAGER, cascade = CascadeType.ALL)
private List<MinutisPrekeTiekejas> tiekejai;

//inverse join of MinutisPrekeTiekejas entity
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="tiek_id")
private MinutisTiekejas minutisTiekejas;

I am building criteria query where I need to check if this entity contains MinutisPrekeTiekejas object with id in array Constants.ID_ARRAY

Something like this (this don't look right and doesn't work, just the priciple):

...
//predicates is a predicate array
predicates.add(from.get("tiekejai").get("tiekId").in(Constants.ID_ARRAY));
...
Minutis
  • 1,193
  • 1
  • 17
  • 47
  • 1
    See http://stackoverflow.com/questions/11297241/how-to-query-an-mn-relationship-with-jpa2/11349052#11349052 and http://stackoverflow.com/questions/11845925/using-a-parameterexpression-as-part-of-the-in-clause/11850967#11850967 – perissf Sep 14 '12 at 13:45
  • Be welcome. It's quite difficult to give a useful answer without knowing some more details about your entities: why you don't have OneToMany in the second class? Anyway if you have got the logic thanks to the links above, you can upvote those answers and delete this question, or write the answer yourself. – perissf Sep 17 '12 at 13:57

0 Answers0