Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling oracle stored procedure from hibernate

prash boy
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to call a stored procedure through hibernate, passing a in parameter and a out parameter.

stored procedure:

create or replace PROCEDURE USER_pref_NEW (User_cv OUT SYS_REFCURSOR,userid in varchar) AS
OPEN User_cv FOR
SELECT * FROM contact where contact.USERID = userid;

hbm file:

<sql-query name="prash_test" callable="true">
<return class="">
{ call USER_pref_NEW(?,:USERID) }


private String userid;
private String firstname;
private String lastname;
private String email;

public String getEmail() {
return email;
public void setEmail(String email) { = email;
public String getFirstname() {
return firstname;
public void setFirstname(String firstname) {
this.firstname = firstname;

public String getUserid() {
return userid;
public void setUserid(String userid) {
this.userid = userid;
public String getLastname() {
return lastname;
public void setLastname(String lastname) {
this.lastname = lastname;

java class calling the stored procedure:

List list =session.getNamedQuery("prash_test").setParameter("USERID","1").list();

Query: I am passing a parameter "userid" when I call the procedure. I use this input parameter to form the "where" clause in the stored procedure query.
I am passing userid as "1" from java, but the result I am getting is "select * from contact" => where clause is being ignored.

Any idea why this could be happening?

Thanks in advance!
Vilpesh Mistry
Ranch Hand
Posts: 62
Eclipse IDE Java
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic