I have the following query. When I execute it I get such error:
[http-nio-8090-exec-9] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 42601
[http-nio-8090-exec-9] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - ERROR: syntax error at or near "."
Position: 5385
I think the problem is in select CG.codes from CodeGroup CG, but how do I write this query correctly? I need to get all the codes that belong to the CodeGroup. The codes is a list of Code.
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("select distinct AI from AppInfo AI ")
.append("left join fetch AI.plan as PSAP ")
.append("where PSAP.edType in ( select C from Code C where C.column1= 'XXXX' ")
.append("and C in (select CG.codes from CodeGroup CG where CG.name = 'YYYY'))");
AIcolumn from AppInfo named ASAI? (select distinct AI from AppInfo AI). So I thinkSQLdoes not understand whichAIdo you want to use therejoin fetch AI.plan.