Reputation: 51
I want to make hibernate query from pojo class, but pojo class uses mappedBy
. I don't know how can I make proper query.
Already I have tried many ideas, like ts.clientAccount.clientAccountMapping.id
but it gives error. clientAccountMapping
is mapped in clientAccount
pojo
first class
public class Transaction{
@ManyToOne
@JoinColumn
private ClientAccount clientAccount;
}
second class
public class ClientAccount{
@JsonIgnore
@OneToMany(mappedBy = "clientAccount", cascade = CascadeType.ALL)
private Set<ClientAccountMapping> clientAccountMapping;
}
third class
public class ClientAccountMapping{
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name="system-uuid", strategy = "uuid")
private String id;
}
Always my compiler gives the following exception:
org.hibernate.QueryException: illegal attempt to dereference collection [transactio0_.idtransactio0_.clientAccount_accountIdclientAccount.clientAccountMapping]
Upvotes: 0
Views: 165
Reputation:
you have to use join here. like : From ClientAccount c join c.clientAccountMapping
Reference : https://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html
Upvotes: 1