I am assuming CustomerInformation
has customerId
field in Long
type:
String hqlString = "select account from Accounts account where account.customerId.customerId=:customerId and account.accountTypeId.accountTypeName=:accountTypeName";
Query query = getSession().createQuery(hqlString);
query.setLong("customerId", customerId);
query.setString("accountTypeName", accountTypeName);
Accounts account = (Accounts) query.uniqueResult(); //if it's not unique then query.list()
I suggest you to rename your classes into Account
and AccountType
. Also don't name an object with id like you did private CustomerInformation customerId;
You will see how screwed hql is written.