Olá pessoal,
Futucando o JPA eu consegui fazer o q eu pensava q n estava disponível, acessar Stored Procedure
pelo JPA, mas vi q tem o NamedNativeQuery pra esse tipo de coisa…
Então fiz o seguinte:
@NamedNativeQuery(name = "spConta2", resultClass = Conta.class, query = "{call sp_cad_conta(?)}",
E com isto consigo acesso a minha SP do SqlServer. Mas n consigo fazer o “mesmo” com o Postgre, mesmo que eu escreva a String Sql
@NamedNativeQuery(name = "spConta2", resultClass = Conta.class, query = "select * from dbo.cad_conta")
Tenho este erro:
[/quote]
[TopLink Warning]: 2009.07.30 12:59:44.893–UnitOfWork(12470752)–Exception [TOPLINK-6044] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRecord(
=> 1
=> JOAO)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(jpahibernate.Conta)
Exception in thread “main” Local Exception Stack:
Exception [TOPLINK-6044] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRecord(
=> 1
=> JOAO)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadAllQuery(jpahibernate.Conta)
at oracle.toplink.essentials.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:823)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:366)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:386)
at oracle.toplink.essentials.queryframework.ObjectBuildingQuery.registerIndividualResult(ObjectBuildingQuery.java:318)
at oracle.toplink.essentials.queryframework.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:511)
at oracle.toplink.essentials.queryframework.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:346)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:724)
at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:692)
at oracle.toplink.essentials.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:746)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:924)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:367)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:478)
at jpahibernate.Main.main(Main.java:35)
Java Result: 1[quote]
Alguma dica?