public Account getByCurrency(Client client, String currency) {
        Account res = null;
        try {
            session = HibernateUtil.getSessionFactory().getCurrentSession();
            res = null;
            String hql = "from Account a where a.client.id=" + client.getClient_id();
            session.beginTransaction();
            Query query = session.createQuery(hql);
            List<Account> accountList = (ArrayList<Account>) query.list();
            for (Account account : accountList) {
                if (account.getCurrency().equals(currency)) {
                    res = account;
                }
            }
            session.getTransaction().commit();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        } finally {
            if (session != null && session.isOpen()) {
                session.close();
            }
        }
        return res;
    }