hibernate - How to get collection by left join that is fetched by sub select via Spring data(JPQL)? -


is possible collection via sub-select , set entity? need find entities restriction , after that, need join them entity.

for example, need find company employees worked in company given date

from pure sql need that:

 select * company c     left join (     select * employee  hiredate > 10.5.2015 , departuredate < 10.12.2015  ) e   on c.id = e.companyid 

i tried via query in spring data doesn't work

@query("select c company c left join fetch (c.employees e e.hiredate > ?1 , e.departuredate < ?1)) c.id = ?2) list<company> findcompanywitemployes(long salary, long companyid); 

entities:

 public class employee{        long id        string name;         date hiredate;       date departuredate;        @manytoone       @joincolumn(name = "companyid", insertable = false, updatable = false)       company company;     }       public class company{        long id        string name;         @onetomany(mappedby="company", cascade=cascadetype.refresh, fetch = fetchtype.lazy)         private set<employee> employees;     } 

i'm getting error:

2016-06-29 11:50:35.824 [serverservice thread pool -- 134] error o.h.hql.internal.ast.errorcounter - line 1:81: expecting ident, found '(' 2016-06-29 11:50:35.824 [serverservice thread pool -- 134] error o.h.hql.internal.ast.errorcounter - line 1:81: expecting ident, found '(' antlr.mismatchedtokenexception: expecting ident, found '('     @ antlr.parser.match(parser.java:211) ~[antlr-2.7.7.jar:na] 

as can see forgot put " before right parenthesis. why getting error.

@query("select c company c left join fetch (c.employees e e.hiredate > ?1 , e.departuredate < ?1)) c.id = ?2 ")


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -