I could reduce the scope of the error:
if I execute this hql with count:
select count(*) from Elemento this where ( ( this in (SELECT this from this.norma.collectionSets col where col.nombre like 'LALA' )) or ('LALA'='*' and this.norma.collectionSets.size > 0) )
The generate sql is:
select count(*) as x0_0_ from sae.ELEMENTO elemento0_ where (((elemento0_.id in(select elemento0_.id from sae.NORMA norma1_, sae.NORMA_COLLECTIONSET collection2_, sae.TIPO tipo3_ where elemento0_.NORMA_ID=norma1_.id and norma1_.id=collection2_.NORMA_ID and collection2_.COLLECTION_SET_ID=tipo3_.id and ((tipo3_.nombre like 'LALA' )))))or(('LALA'='*' )and((select count(*) from sae.NORMA norma4_, sae.NORMA_COLLECTIONSET collection5_ where elemento0_.NORMA_ID=norma4_.id and norma4_.id=collection5_.NORMA_ID)>0 )))
...and It's execute successful
if I execute this hql:
select new com.laley.sae.view.dto.DocumentoDTOLegislacionConsolidada(this.documentoLegislacionConsolidada.id, this.documentoLegislacionConsolidada.guid, this.fechaVigenciaInicial, this.fechaVigenciaFinal, this.tipoElemento.nombre, this.descripcion,this.norma.jurisdiccion.sigla, this.fechaOrdenamiento, this.norma)from Elemento this where ( ( this in (SELECT this from this.norma.collectionSets col where col.nombre like 'LALA' )) or ('LALA'='*' and this.norma.collectionSets.size > 0) ) order by this.norma.jurisdiccion.descripcion, this.norma.emisiones.elements.emisor.descripcion, this.norma.emisiones.elements.tipoDeNorma.sigla, this.norma.emisiones.elements.numeroNorma, this.fechaOrdenamiento DESC, this.ordenInterno, this.descripcion, this.fechaVigenciaFinal DESC
The generate sql is:
select norma4_.id as id, norma4_.version as version, norma4_.tcNorma as tcNorma, norma4_.EDICION_ANTERIOR_ID as EDICION_4_, norma4_.EDICION_POSTERIOR_ID as EDICION_5_, norma4_.fechaCarga as fechaCarga, norma4_.fechaPublicacion as fechaPub7_, norma4_.fechaVigenciaInicial as fechaVig8_, norma4_.GUIDnormaGeneradora as GUIDnorm9_, norma4_.JURISDICCION_ID as JURISDI10_, norma4_.notasEspeciales as notasEs11_, norma4_.notasInternas as notasIn12_, norma4_.notasHistoria as notasHi13_, norma4_.notasVigencia as notasVi14_, norma4_.publicacion as publica15_, norma4_.BASE_ORIGEN_ID as BASE_OR16_, norma4_.fechaCreacion as fechaCr17_, norma4_.fechaModificacion as fechaMo18_, elemento0_.DOCUMENTO_LEG_CONS_ID as x0_0_, documentol11__1_.GUID as x1_0_, elemento0_.fechaVigenciaInicial as x2_0_, elemento0_.fechaVigenciaFinal as x3_0_, tipo12_.nombre as x4_0_, elemento0_.descripcion as x5_0_, jurisdicci6_.SIGLA as x6_0_, elemento0_.fechaOrdenamiento as x7_0_, norma4_.id as x8_0_ from sae.ELEMENTO elemento0_, sae.JURISDICCION jurisdicci6_, sae.NORMA_EMISIONES emisiones7_, sae.EMISION emision8_, sae.EMISORLEGISLACION emisorlegi9_, sae.TIPODENORMA tipodenorm10_, sae.DOCUMENTO_LEGISLACION_CONS documentol11_, sae.DOCUMENTO documentol11__1_, sae.TIPO tipo12_ where elemento0_.NORMA_ID=norma4_.id and norma4_.JURISDICCION_ID=jurisdicci6_.JURISDICCIONID and elemento0_.NORMA_ID=norma4_.id and norma4_.id=emisiones7_.NORMA_ID and emisiones7_.EMISION_ID=emision8_.id and emision8_.EMISOR_LEGISLACION_ID=emisorlegi9_.EMISORLEGISLACIONID and elemento0_.NORMA_ID=norma4_.id and norma4_.id=emisiones7_.NORMA_ID and emisiones7_.EMISION_ID=emision8_.id and emision8_.TIPO_NORMA_ID=tipodenorm10_.TIPODENORMAID and elemento0_.NORMA_ID=norma4_.id and norma4_.id=emisiones7_.NORMA_ID and emisiones7_.EMISION_ID=emision8_.id and elemento0_.DOCUMENTO_LEG_CONS_ID=documentol11_.PADRE_ID and documentol11_.PADRE_ID=documentol11__1_.DOCUMENTOID(+) and elemento0_.TIPO_ELEMENTO_ID=tipo12_.id and elemento0_.NORMA_ID=norma4_.id and ((((elemento0_.id in(select elemento0_.id from sae.NORMA norma1_, sae.NORMA_COLLECTIONSET collection2_, sae.TIPO tipo3_ where elemento0_.NORMA_ID=norma1_.id and norma1_.id=collection2_.NORMA_ID and collection2_.COLLECTION_SET_ID=tipo3_.id and ((tipo3_.nombre like 'LALA' )))))or(('LALA'='*' )and((select count(*) from sae.NORMA norma4_, sae.NORMA_COLLECTIONSET collection5_ where elemento0_.NORMA_ID=norma4_.id and norma4_.id=collection5_.NORMA_ID)>0 )))) order by jurisdicci6_.DESCRIPCION , emisorlegi9_.DESCRIPCION , tipodenorm10_.SIGLA , emision8_.numeroNorma , elemento0_.fechaOrdenamiento DESC , elemento0_.ordenInterno , elemento0_.descripcion , elemento0_.fechaVigenciaFinal DESC
and the result It's
25-oct-2006 18:12:39 ERROR JDBCExceptionReporter:58 - ORA-00904: "NORMA4_"."ID": invalid identifier
SUMMARY: with count pass and with a select "property"... + and some "order" ==> fails
|