Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with NamedQuery in hbm.xml

 
regoj nastocare
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Good Morning all

well, i have a query like this



private final String SELECT = "select paguinid.folio, paguin, Institucion " + "\n" +
"from Paguin paguin, Institucion Institucion " + "\n" +
"where paguinid.cveEntidad = 'patito' " + "\n" +
"and paguin.id.idEmpresa = 8

private final String ORDENTOPO = SELECT + "and paguin.envio = '1' " + "\n" +
"and paguin.reenvio = '1' " + "\n" +
"and paguin.verificado = '1' " + "\n" +
"and paguin.envio = '0' " + "\n" +
"and paguin.cancelacion = '0' " + "\n" +
"and Institucion.id.cveEntidad = paguin.id.cveEntidad " + "\n" +
"and Institucion.id.idEmpresa = paguin.id.idEmpresa " + "\n" +
"and Institucion.id.idInstitucion = paguin.idInstitucionBen " + "\n";

then i create a session and execute this line

sSQL = ORDENTOPO + " and paguin.topologia = 'T' " + "\n" +
"and paguin.prioridad = 1 " + "\n" +
"order by paguin.id.folio";

List_ENVIO = Session_ENVIO.createQuery( sSQL ).setMaxResults(OrdenesPorPaquete).list();

After that all its ok i recive the list, i create a Iterator from the list and i cast

Iterator Iterator_ENVIO = List_ENVIO.iterator();

///CAST to object

while( Iterator_ENVIO.hasNext() ) {

Object[] Object_ENVIO = (Object[]) Iterator_ENVIO.next();

Object Object_Envio = Object_ENVIO[1];

if(Object_Envio == null) {
logger_.info("Nothing finded.");
}

this its working fine

but when i externalize my query, look i have a Canonica.hbm.xml with all the clases i add this, the same query

...
<query name="ORDENTOPOX">
<![CDATA[
select paguin.id.folio, Paguin, Institucion
from Paguin paguin, Institucion Institucion
where SpeiEnvio.id.cveEntidad = 'MONEX'
and paguin.id.idEmpresa = 8
and paguin.envio = '1'
and paguin.reenvio = '1'
and paguin.verificado = '1'
and paguin.envio = '0'
and paguin.cancelacion = '0'
and Institucion.id.cveEntidad = paguin.id.cveEntidad
and Institucion.id.idEmpresa = paguin.id.idEmpresa
and Institucion.id.idInstitucion = paguin.idInstitucionBen
and paguin.topologia = 'T'
order by paguin.id.folio
]]>
</query>
...



in code

List_ENVIO = Session.getNamedQuery("ORDENTOPOX").setMaxResults(OrdenesPorPaquete).list();

RETURN ME

then return 11:18:26:359 INFO[Thread_POLEO](Thread_Poleo.java)-Recorriendo Objetos.
java.lang.ClassCastException: com.empre.pagos.hibernate.Paguin cannot be cast to [Ljava.lang.Object;
at com.empre.pagos.thread.Thread_Poleo.run(Thread_Poleo.java:240)
at java.lang.Thread.run(Unknown Source)
11:18:26:359 ERROR[Thread_POLEO](Thread_Poleo.java)-Thread_Poleo Procesa Mensaje=com.sies.pagoselectronicos.hibernate.SpeiEnvio cannot be cast to [Ljava.lang.Object;->java.lang.ClassCastException: com.sies.pagoselectronicos.hibernate.SpeiEnvio cannot be cast to [Ljava.lang.Object;->com.sies.pagoselectronicos.hibernate.SpeiEnvio cannot be cast to [Ljava.lang.Object;->[Ljava.lang.StackTraceElement;@ebaf12
11:18:26:359 INFO[Thread_POLEO](Thread_Poleo.java)

is my namedquery bad??? cant be cross select in external query??


if i run

sSQL = "select paguin.id.folio, Paguin, Institucion " + "\n" +
"from Paguin paguin, Institucion Institucion " + "\n" +
"where paguin.id.cveEntidad = 'patito' " + "\n" +
"and paguin.id.idEmpresa = 8 " + "\n" +
"and paguin.envio = '1' " + "\n" +
"and paguin.reenvio = '1' " + "\n" +
"and paguin.verificado = '1' " + "\n" +
"and paguin.envio = '0' " + "\n" +
"and paguin.cancelacion = '0' " + "\n" +
"and Institucion.id.cveEntidad = paguin.id.cveEntidad " + "\n" +
"and Institucion.id.idEmpresa = paguin.id.idEmpresa " + "\n" +
"and Institucion.id.idInstitucion = paguin.idInstitucionBen " + "\n" +
"and paguin.topologia = 'T' " + "\n" +
"order by paguin.id.folio";
List_SPEIENVIO = Session_SPEI.createQuery( sSQL ).setMaxResults(OrdenesPorPaquete).list();

works normally

THAAAAANK YOUUUUU
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic