-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: I need to extract of a consultation two values of my Class
PostPosted: Fri Jan 26, 2007 1:53 pm 
Newbie

Joined: Mon Jul 17, 2006 11:49 pm
Posts: 3
Location: Venezuela
Hibernate version:[3.1]

[b]Mapping documents: The information of mapping is in the file spring.xml, since spring and hibernate interact together in the application. Next I show the data most important of spring.xml to obtain sessionFactory

<bean id="dataSourceComite" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>***</value>
</property>
<property name="username">
<value>***</value>
</property>
<property name="password">
<value>***</value>
</property>
</bean>
<!-- Fin de Definición de Data Source-->

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSourceComite"/>
</property>
<property name="mappingResources">
<list>
<value>ve/com/venezolano/comite/servicios/to/LcInstituciones.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaBancosNacionales.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaBancosInternacionales.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoOperacion.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcCuentaPersona.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcSolicitud.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcDetalleFinanzas.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaComite.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcTipoSolicitud.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaResolucion.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaEstatus.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcEmpleados.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaInstrumento.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcCargos.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoCredito.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcTipoSolicitudCredito.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaDestinoCredito.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaCuotaIntereses.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaNacionalidad.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcParametrosComite.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoGarantia.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcGarantia.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcDetalleGarantia.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaMonedas.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcTasaCambio.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaCasaMatriz.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaFormaPago.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcDetalleCreditos.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/LcCuentaBancaria.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaPaises.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoComision.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoTarjeta.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoCartaCredito.hbm.xml</value>
<value>ve/com/venezolano/comite/servicios/to/ListaTipoConvenio.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>

[b]Code between sessionFactory.openSession() and session.close():


String query = "select LcSolicitud.monto, LcSolicitud.fecha from LcSolicitud";
Iterator iterador = session.createQuery(query).iterate();
while (iterador.hasNext())
{
Object[] fila = (Object [])iterador.next();
System.out.print("Amount :" + fila[0]);
System.out.print("Type Solicitud :" + fila[1]);
}

Full stack trace of any exception that occurs:

java.lang.NullPointerException

at org.hibernate.hql.ast.tree.IdentNode.resolveAsNakedComponentPropertyRefLHS(IdentNode.java:195)

at org.hibernate.hql.ast.tree.IdentNode.resolve(IdentNode.java:85)

at org.hibernate.hql.ast.tree.DotNode.resolveFirstChild(DotNode.java:139)

at org.hibernate.hql.ast.HqlSqlWalker.lookupProperty(HqlSqlWalker.java:462)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1080)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1877)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1821)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1392)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:553)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)

at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)

at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)

at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:110)

at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)

at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)

at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)

at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)

at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:111)

at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1581)

at ve.com.venezolano.comite.servicios.bf.SolicitudBf.consultarReporte(SolicitudBf.java:1422)

at ve.com.venezolano.comite.servicios.bf.SolicitudBf.main(SolicitudBf.java:1437)


Name and version of the database you are using:

Oracle 9.1

The generated SQL (show_sql=true):

Don't generate.

I want to obtain field of my class both and it always generates a NullPointerException, would thank for the aid that can render to me.

I have made other consultations where I do not indicate the salient fields and here I do not have problems.

_________________
Darlys Maldonado


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 26, 2007 3:09 pm 
Newbie

Joined: Mon Aug 15, 2005 10:02 am
Posts: 7
Hi,

Just use aliases:
Code:
select lc.monto, lc.fecha from LcSolicitud lc


Eugênio.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.