I\'m writing java application using hibernate 5.2
but without HQL
there is two table, Transactions
and ResponseCode
You have mapped a single ResponseCode
entity in Transaction
, which is wrong. The response code is not a PK, it does not uniquely identifies a ResponseCode entity for a given Transaction entity. E.g. for a transaction with response code 000
there are 2 ResponseCode entities (with 'en' and 'ge' langs).
I recommend you to try to map a collection instead.
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name="rc")
private List rcList;
Since your query WHERE conditions apply to the Transaction only, you can simply query the Transaction entities. Hibernate cache will optimize the eventual subqueries you need for each response code (one query for '000', one for '116', etc).