Jump to content
Changes to the Jaspersoft community edition download ×

Parameter content in HQL


Recommended Posts

Hi all,

I've got a problem with one report. I'm using HQL in the query and I need to pass and expresion in WHERE block (i.e.

FROM mypackage.MyClass as object

WHERE ( $P{expresion} )


and $P{expresion} could be,

"object.property = 1 OR object.property = 4"


,however when I try perform this I received the exception


[10 nov 2006 10:53:54,343][ERROR] [org.hibernate.hql.PARSER (reportError)] <AST>:12:9: unexpected AST node: :


The query is :

[sELECT bs.id.codEstudio as codEstudio, bs.id.fechaRecepcion as fechaRecepcion, bs.id.hisClinica as hisClinica, bs.id.edad as edad, bs.id.fotosMacro as fotosMacro, bs.id.fotosMicro as fotosMicro, bs.id.casoInteresante as casoInteresante,

bs.id.codSnomed as codSnomed, bs.id.snomed as snomed,

bs.id.nombre as pacienteNombre, bs.id.apellido1 as pacienteApellido1, bs.id.apellido2 as pacienteApellido2, bs.id.sexo as sexo

FROM es.ingenia.infopat.modelo.informes.vistas.VdbInformesBusquedaSnomeds bs

WHERE (bs.id.tipoEstudio = :_tipoEstudio OR :_tipoEstudio = '')

AND (bs.id.sexo = :_sexo OR :_sexo = '')

AND (bs.id.casoInteresante = :_casoInteresante)

AND ( (bs.id.fotosMacro > 0 AND :_fotosMacro = true) OR :_fotosMacro = false )

AND ( (bs.id.fotosMicro > 0 AND :_fotosMicro = true) OR :_fotosMicro = false )

AND (bs.id.fechaRecepcion BETWEEN :_fechaInicio AND :_fechaFin)

AND (bs.id.edad BETWEEN :_edadInicio AND :_edadFin)

AND ( :_expresion )]


the fail is in the last parameter :_expresion, it seems that jasper parses the "prepare" query before exchange parameter names by parameter values.


Any idea about this issue?


Thanks in advance.


Best regards,

Justo Aguilar.




You could make a fast and easy example with a query like this:

FROM AnyOfYourClasses

WHERE ( $P{expression} )


where $P{expresion} could be 1 = 1


Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...