lundi 20 avril 2015

Subquery in JPQL (multiple select)

I have deux tables in my datables. The Account table and the AccountType table. I need a JPQL query to retrieve all accounts with column kind(in table AccountType) equal "BalanceSheet", I also need another one to retrieve all accounts witch the column kind(in table AccountType) equal "Outturn".

I try this put the don't works.

Query query = daoFactory
            .getEntityManager()
            .createQuery(
                    "SELECT a FROM Account a WHERE a.deleted=false AND a.type_id IN (SELECT id FROM "
                    + "AccountType WHERE deleted=false AND kind='BalanceSheet')");
List<Account> result = query.getResultList();

Aucun commentaire:

Enregistrer un commentaire