Sympathisant: SQL / HQL - unterschiedliche Results (PostgreSQL)

Beitrag lesen

Hallo allerseits,

ich habe den Zustand, dass mir ein SQL-Statement als Ergebniss genau 2 Datensaetze liefert. Das selbe Statement in HQL (Hibernate Query Language) liefert mir jedoch nur 1 Datensatz. Und ich verstehe nicht warum.
Vielleicht sehe ich den Wald vor lauter Baeumen nicht mehr. Daher mal hier in die Runde gefragt, ob ihr einen signifikanten Unterschied der beiden Statements erkennt.

Hier das funktionierende SQL-Statement:

  
  
            select  
                       account.id, account.name,count(*)  
            from  
                       scan  
            inner join  
                       tag on scan.tag_id = tag.id  
            inner join  
                       account on tag.account_id = account.id  
            where  
                       scan.date_scanned >=  
                       (select max(scansub.date_scanned) from scan as scansub where scansub.unique_id = scan.unique_id)  
            group by  
                       account.id, account.name  

Hier das HQL-Statement

  
  
            select  
                            Account.id, Account.name, count(*)  
            from  
                            Scan as Scan  
            inner join  
                            Scan.tag as Tag  
            inner join  
                            Tag.account as Account  
            where  
                            Scan.dateScanned >=  
                            (select max(Scansub.dateScanned) from Scan as Scansub where Scansub.uniqueId = Scan.uniqueId)  
            group by  
                            Account.id, Account.name  

MfG,
Sympatisant

--
"Non dura iubeantur, non prohibeantur inpura."