users@glassfish.java.net

NamedNativeQuery and problems !!!

From: <glassfish_at_javadesktop.org>
Date: Thu, 15 May 2008 07:28:27 PDT

Hi All,

I'm trying to execute this NamedNativeQuery without success...
[code]
@SqlResultSetMapping(name = "dadosEleitor", entities = @EntityResult(entityClass = business.vo.DadosEleitor.class, fields = {
                @FieldResult(name = "NUM_INSCRICAO", column = "INS"),
                @FieldResult(name = "NOM_ELEITOR", column = "NOM"),
                @FieldResult(name = "NOM_LOCAL", column = "LOC"),
                @FieldResult(name = "NOM_BAIRRO", column = "BAR"),
                @FieldResult(name = "DES_ENDERECO", column = "END"),
                @FieldResult(name = "NUM_ZONA", column = "ZON"),
                @FieldResult(name = "NUM_SECAO", column = "SEC"),
                @FieldResult(name = "NOM_LOCALIDADE", column = "MUN"),
                @FieldResult(name = "SGL_UF", column = "UF"),
                @FieldResult(name = "SGL_PARTIDO", column = "PAR"),
                @FieldResult(name = "IND_SITUACAO", column = "IND") }))
@NamedNativeQuery(name = "Dados", query = "SELECT E.NUM_INSCRICAO AS INS, E.NOM_ELEITOR AS NOM, L.NOM_LOCAL AS LOC, B.NOM_BAIRRO AS BAR, L.DES_ENDERECO AS END, Z.NUM_ZONA AS ZON, S.NUM_SECAO AS SEC, M.NOM_LOCALIDADE AS MUN, U.SGL_UF AS UF, NVL(P.SGL_PARTIDO,'NÃO FILIADO') AS PAR, NVL(F.IND_SITUACAO,'0') AS IND FROM ((((((((((ELEITOR E JOIN SECAO S ON E.COD_OBJETO_SECAO = S.COD_OBJETO) JOIN LOCAL_VOTACAO L ON S.COD_OBJETO_LOCAL = L.COD_OBJETO) JOIN LOCALIDADE M ON L.COD_OBJETO_LOCALIDADE = M.COD_OBJETO) JOIN ZONA Z ON L.COD_OBJETO_ZONA =Z.COD_OBJETO) JOIN BAIRRO B ON L.COD_OBJETO_BAIRRO = B.COD_OBJETO) JOIN UF U ON U.COD_OBJETO = Z.COD_OBJETO_UF) LEFT JOIN FILIADO F ON F.NUM_INSCRICAO = E.NUM_INSCRICAO) LEFT JOIN LISTA_FILIADO LF ON F.COD_OBJETO_LISTA_FILIADO = LF.COD_OBJETO) LEFT JOIN LISTA LS ON LF.COD_OBJETO_LISTA=LS.COD_OBJETO) LEFT JOIN PARTIDO P ON LS.COD_OBJETO_PARTIDO= P.COD_OBJETO) WHERE (E.COD_FON_NOME_ELEITOR = ?1) AND (E.DAT_NASC = ?2)", resultSetMapping = "dadosEleitor")
[/code]


this is my dao
[code]
List<DadosEleitor> dadosEleitores = query.getResultList();
[/code]


And I received a NPE. This is the exception.
[code]
Exception in thread "main" java.lang.NullPointerException
        at oracle.toplink.essentials.queryframework.EntityResult.getValueFromRecord(EntityResult.java:158)
        at oracle.toplink.essentials.queryframework.ResultSetMappingQuery.buildObjectsFromRecords(ResultSetMappingQuery.java:153)
        at oracle.toplink.essentials.queryframework.ResultSetMappingQuery.executeDatabaseQuery(ResultSetMappingQuery.java:201)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)[TopLink Warning]: 2008.05.15 10:31:25.523--UnitOfWork(12413535)--Thread(Thread[main,5,main])--java.lang.NullPointerException
        at oracle.toplink.essentials.queryframework.EntityResult.getValueFromRecord(EntityResult.java:158)
        at oracle.toplink.essentials.queryframework.ResultSetMappingQuery.buildObjectsFromRecords(ResultSetMappingQuery.java:153)
        at oracle.toplink.essentials.queryframework.ResultSetMappingQuery.executeDatabaseQuery(ResultSetMappingQuery.java:201)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:609)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:536)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2219)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:346)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:453)
        at persistence.dao.EleitorDaoImpl.findDados(EleitorDaoImpl.java:50)
        at persistence.dao.EleitorDaoImpl.findDadosEleitor(EleitorDaoImpl.java:25)
        at test.Tester.main(Tester.java:22)
 
 
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2219)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:937)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:346)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:453)
        at persistence.dao.EleitorDaoImpl.findDados(EleitorDaoImpl.java:50)
        at persistence.dao.EleitorDaoImpl.findDadosEleitor(EleitorDaoImpl.java:25)
        at test.Tester.main(Tester.java:22)
[/code]


Any help is appreciate.

10ks.
[Message sent by forum member 'roger_gomes' (roger_gomes)]

http://forums.java.net/jive/thread.jspa?messageID=274587