Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @NamedStoredProcedureQuery problem(@NamedStoredProcedureQuery)
@NamedStoredProcedureQuery problem [message #488449] Mon, 28 September 2009 17:14 Go to next message
Andres1981  is currently offline Andres1981 Friend
Messages: 2
Registered: September 2009
Junior Member
Hi, i'm using JPA + oracle 10g + websphere 6.1 + eclipselink

i'm trying to implement a @NamedStoredProcedureQuery annotation to call a stored procedure in my DB

Here's the code of the SP

Code:
CREATE OR REPLACE PROCEDURE PORTAL.TEST (VALUEX IN NUMBER)
AS
VAR1 NUMBER;
BEGIN

SELECT VALUEX INTO VAR1 FROM DUAL;
END TEST;
/


The SP doesn't return any value, i'm just trying to get access into with my entity manager

Here's the code of the @NamedStoredProcedureQuery annotation in my entity

Code:
@NamedStoredProcedureQueries(
@NamedStoredProcedureQuery(name="SP_TEST", procedureName="PORTAL.TEST",
parameters={
@StoredProcedureParameter(name="VALUEX",
queryParameter="VALUEX",
type=int.class,
direction=Direction.IN)

},
resultClass= void.class,
returnsResultSet = false
)
)

Now this is the code for calling the store procedure with an em

Code:
Query query;
query = entityManager.createNamedQuery("SP_TEST")
.setParameter("VALUEX", numeroArea);
query.getSingleResult();

And i got the following exception:

Code:
exception:java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement incompatible with java.sql.CallableStatement
at org.eclipse.persistence.internal.databaseaccess.DatabasePlat form.executeStoredProcedure(DatabasePlatform.java:1681)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAcce ssor.basicExecuteCall(DatabaseAccessor.java:567)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAcce ssor.executeCall(DatabaseAccessor.java:500)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteCall(AbstractSession.java:855)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:204)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeCall(DatasourceCallQueryMechanism.java:190)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeSelectCall(DatasourceCallQueryMechanism.jav a:261)
at org.eclipse.persistence.internal.queries.DatasourceCallQuery Mechanism.executeSelect(DatasourceCallQueryMechanism.java:24 3)
at org.eclipse.persistence.queries.ResultSetMappingQuery.execut eDatabaseQuery(ResultSetMappingQuery.java:203)
at org.eclipse.persistence.queries.DatabaseQuery.execute(Databa seQuery.java:666)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitO fWork(DatabaseQuery.java:585)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.int ernalExecuteQuery(UnitOfWorkImpl.java:2587)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1178)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1162)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1136)
at org.eclipse.persistence.internal.sessions.AbstractSession.ex ecuteQuery(AbstractSession.java:1118)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeRea dQuery(EJBQueryImpl.java:399)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleR esult(EJBQueryImpl.java:547)
at mx.com.afirme.midas.catalogos.zonacresta.ZonaCrestaFacade.ob tieneIdZonaCresta(ZonaCrestaFacade.java:197)
at mx.com.afirme.midas.catalogos.zonacresta.EJSRemote0SLZonaCre staFacade_3b7d5a3c.obtieneIdZonaCresta(EJSRemote0SLZonaCrest aFacade_3b7d5a3c.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.rmi.util.ProxyUtil$4.run(ProxyUtil.java:726)
at java.security.AccessController.doPrivileged(AccessController .java:246)
at com.ibm.rmi.util.ProxyUtil.invokeWithClassLoaders(ProxyUtil. java:724)
at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java :1160)
at $Proxy35.obtieneIdZonaCresta(Unknown Source)
at mx.com.afirme.midas.catalogos.zonacresta._ZonaCrestaFacadeRe mote_Stub.obtieneIdZonaCresta(_ZonaCrestaFacadeRemote_Stub.j ava)
at mx.com.afirme.midas.catalogos.zonacresta.ZonaCrestaSN.obtien eIdZonaCresta(ZonaCrestaSN.java:201)
at mx.com.afirme.midas.catalogos.zonacresta.ZonaCrestaDN.obtien eIdZonaCresta(ZonaCrestaDN.java:114)
at mx.com.afirme.midas.catalogos.zonacresta.ZonaCrestaAction.li star(ZonaCrestaAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.apache.struts.actions.DispatchAction.dispatchMethod(Disp atchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAct ion.java:170)
at org.apache.struts.actions.MappingDispatchAction.execute(Mapp ingDispatchAction.java:166)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execu te(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execu te(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(A ctionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.ja va:190)
at org.apache.commons.chain.generic.LookupCommand.execute(Looku pCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.ja va:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(C omposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet .java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet. java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(Servl etWrapper.java:1151)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(Servl etWrapper.java:1086)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(We bAppFilterChain.java:145)
at mx.com.afirme.midas.sistema.seguridad.Filtro.doFilter(Filtro .java:117)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilte r(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(We bAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(W ebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter( WebAppFilterManager.java:834)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter( WebAppFilterManager.java:682)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest (ServletWrapper.java:588)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleReque st(ServletWrapper.java:489)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.j ava:3453)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGro up.java:267)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContai ner.java:815)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebCont ainer.java:1466)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChanne lLink.java:119)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleD iscrimination(HttpInboundLink.java:458)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleN ewInformation(HttpInboundLink.java:387)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.com plete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.future Completed(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(Abstract AsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(As yncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:1 96)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(Result Handler.java:751)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)

am i missing something? Any help would be appreciated

Regards

Andres1981
Re: @NamedStoredProcedureQuery problem [message #489085 is a reply to message #488449] Thu, 01 October 2009 13:25 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This seems to be some kind of bug in the WebSphere DataSource. It seems to be wrapping your JDBC drivers CallableStatetment with a PreparedStatement wrapper.

You may wish to report this issue to WebSphere.

Do you execute the same SQL as the procedures uses as plain SQL elsewhere? This could potentially make WAS cache a prepared statement for the SQL, otherwise CallableStatements may not work at all in WAS, you may wish to try this with raw JDBC and the WAS DataSource.

There is an API on the EclipseLink DatabaseQuery (isNativeConnectionRequired(true), or the JPA Query hint "eclipselink.jdbc.native-connection", which should resolve the issue by unwrapping the DataSource before creating the statement.

You could also use EclipseLink internal connection pooling to avoid the WAS DataSource.


James : Wiki : Book : Blog : Twitter
Previous Topic:Can not generate orm.xml using Galileo SP1
Next Topic:Using @ManyToOne with a @JoinTable
Goto Forum:
  


Current Time: Mon Dec 22 10:38:15 GMT 2014

Powered by FUDForum. Page generated in 0.01493 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software