| Author |
. java.lang.IllegalArgumentException: callable not yet supported for native queries
|
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
hi,
All i am trying to insert data in database by using store procedure .
i am getting error .please find the solution..
1.
2.
3. java.lang.IllegalArgumentException: callable not yet supported for native queries
4. at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:171)
5. at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1190)
6. at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:357)
7. at com.lara.Dao.LoginDao.saveUser(LoginDao.java:49)
8. at com.lara.web.LoginAction.execute(LoginAction.java:48)
9. at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
10. at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
11. at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
12. at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
13. at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
14. at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
15. at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
16. at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
17. at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
18. at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
19. at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
20. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
21. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
22. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
23. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
24. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
25. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
26. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
27. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
28. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
29. at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
30. at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
31. at java.lang.Thread.run(Thread.java:735)
32.
33.
34.
java.lang.IllegalArgumentException: callable not yet supported for native queries at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:171) at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1190) at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:357) at com.lara.Dao.LoginDao.saveUser(LoginDao.java:49) at com.lara.web.LoginAction.execute(LoginAction.java:48) at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58) at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.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:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:735)
my code is....
this is
the method where i calling store procedure....
view plaincopy to clipboardprint?
1.
2.
3.
4. public void saveUser(User user) {
5. System.out.println("I am inside LoginDao class");
6. Session session = HibernateUtill.currentSession();
7. Transaction tx = null;
8. int id=user.getId();
9. String username=user.getUsername();
10. String password=user.getPassword();
11. System.out.println("id......................"+id);
12. System.out.println("username...................."+username);
13. System.out.println("password......................"+password);
14.
15. boolean rollback = true;
16. try {
17.
18. System.out.println("1");
19. Query qry = session.getNamedQuery("selectAllEmployees_SP");
20. qry.setInteger(0, id);
21. qry.setString(1, username);
22. qry.setString(2, password);
23. System.out.println("2");
24.
25. qry.executeUpdate();
26.
27. System.out.println("3");
28. System.out.println("the data"+qry);
29. rollback = false;
30. }
31. catch (Exception e) {
32. e.printStackTrace();
33. }
34. finally {
35. if( rollback && tx != null){
36. tx.rollback();
37. }
38. HibernateUtill.closeSession();
39. }
40.
41. }
42.
43.
44.
this is hbm.xml file
view plaincopy to clipboardprint?
1.
2.
3. <?xml version="1.0" encoding="UTF-8"?>
4. <!DOCTYPE hibernate-mapping PUBLIC
5. "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
6. "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
7.
8. <hibernate-mapping package="com.lara.pojo">
9. <class name="com.lara.pojo.User" table="login_table" >
10. <id name="id" type="java.lang.Integer" column="id">
11.
12. </id>
13. <property name="username" column="username"/>
14. <property name="password" column="password"/>
15. <loader query-ref="selectAllEmployees_SP" />
16.
17. </class>
18. <sql-query name="selectAllEmployees_SP" callable="true">
19. <return class="com.lara.pojo.User" alias="emp" >
20. <return-property name="id" column="id"/>
21. <return-property name="username" column="username"/>
22. <return-property name="password" column="password"/>
23.
24. </return>
25. { call login_table2(?,?,?)}
26. </sql-query>
27.
28. </hibernate-mapping>
29.
this is store procedure
please solve this problem
thanks
Raj jaiswal
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
The error is telling you you are trying to use features Hibernate does not support. Have a read of the documentation to see the limitations Hibernate places on stored procedures.
A couple of questions popped up in my head looking at your code:
What are you using an SP at all for such a simple insert? Is it not easier to just insert the record via the Hibernate API?How come you have an SP referred to as "selectAllEmployees_SP" that actually does an insert?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
hi
Actually I am using mssql sever 2005 .I study that documentation and I am also follow hibernate api or syntax.
Even this is simlple insert operation but after that i will use complex one .
so please try to solve this issues.
thanks
raj jaiswal
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Did you read the documentation? Even the bit about how the "procedure must return a result set"?
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
yes i read the documentation ,there written store procedure must be return resultset .so where could be changes need to do..
I am beginner of hibernate application .
thanks
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
OK, well my first question would be why are you using Hibernate with stored procedures? It is not usually something you would choose to do; after all there is no point accessing your database through an ORM if all you are accessing is database specific logic.
To get your SP working, you need to change the syntax of the call (see the link for an example) and your SP needs to return results.
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
Sorry i didn't get .
are you telling about this call { call login_table2(?,?,?)}
what is link you said .
give some example so i will understand better.
thanks
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
I'm talking about how you call your stored procedure from your Hibernate code (the link has a good example - all I could do is repeat it here. Please read the linked documentation) and how you have written the procedure.
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
please tell me what is the correct way of calling store procedure in hibernate....
if you have any sample please send me...
this is my store procedure code
thanks
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
raj jaiswal wrote:please tell me what is the correct way of calling store procedure in hibernate....
The syntax (including an example) is shown in the link I provided.
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
can you please send me that link.....
thanks
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
send me link
|
 |
raj jaiswal
Ranch Hand
Joined: Nov 25, 2008
Posts: 56
|
|
Thanks very much Paul Sturrock .
finally i got solution.
thanks & regards
raj jaiswal
|
 |
Nelson Salazar
Greenhorn
Joined: May 13, 2011
Posts: 1
|
|
raj jaiswal wrote:Thanks very much Paul Sturrock .
finally i got solution.
thanks & regards
raj jaiswal
hi raj, can you post your solution?? now i have same problem.
thanks.-
|
 |
 |
|
|
subject: . java.lang.IllegalArgumentException: callable not yet supported for native queries
|
|
|