Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9100621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:54:45+00:00 2026-06-17T00:54:45+00:00

I have created a MySQL Stored Procedure for a Student Class like this,I want

  • 0

I have created a MySQL Stored Procedure for a Student Class like this,I want to call this Stored Procedure in Hibernate

Stored Procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `StudentProcedure`$$

CREATE  PROCEDURE `StudentProcedure`(IN studentNo varchar(12) )
BEGIN
SELECT SNAME FROM Student WHERE SNO=studentNo;
END$$

DELIMITER ;

My Pojo class:

package edu.model;

public class Student {
    private String studentNo;
    private String studentName;
    public String getStudentNo() {
        return studentNo;
    }
    public void setStudentNo(String studentNo) {
        this.studentNo = studentNo;
    }
    public String getStudentName() {
        return studentName;
    }
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }
}

HBM File:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="edu.model.Student" table="Student">
        <id name="studentNo" column="SNO">
        <generator class="assigned"/>           
        </id>
        <property name="studentName">
            <column name="SNAME" />
        </property>
    </class>
    <sql-query name="StudentProcedure" callable="true">
    <return alias="student" class="edu.model.Student">
    <return-property name="studentName" column="SNAME">
    </return-property>
    </return>
    <![CDATA[CALL StudentProcedure(:studentNo)]]>   
    </sql-query>
</hibernate-mapping>

TestClass:

 package edu.test;

    import org.hibernate.HibernateException;
    import org.hibernate.Query;
    import org.hibernate.Session;
    import org.hibernate.Transaction;
    import edu.model.Student;
    import edu.util.SessionUtil;

    public class ProcedureTest {
        public static void main(String args[]) {
            Session session = SessionUtil.getSession();
            Transaction tx = session.beginTransaction();
            try {
                Query query = session.getNamedQuery("StudentProcedure");
                System.out.println("Test");
                query.setParameter("studentNo","123");
                Student student = (Student)query.uniqueResult();            
                System.out.println("Student Name:" + student.getStudentName());
            } catch (HibernateException e) {
                System.err.println("Hibernate Exception>>>"+e.getClass().getName()+"..........+"+e.getMessage());
                tx.rollback();
            }
        }
    }

When I run My class I am facing the below Exception:

SEVERE: Column 'SNO0_0_' not found.
Hibernate Exception>>>org.hibernate.exception.SQLGrammarException..........+could not execute query

Could any one help me
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:54:47+00:00Added an answer on June 17, 2026 at 12:54 am

    http://blog.unidev.com/index.php/2009/03/03/calling-oracle-stored-procedure-from-hibernate/

    You also need to define return property for the SNO

    <return-property name="studentNo" column="SNO">
    </return-property>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a MySQL Stored Procedure DELIMITER $$ DROP PROCEDURE IF EXISTS
I have stored procedure that I created in MySQL and want PHP to call
This has me seriously stumped. I have a MySQL stored procedure that looks like
I have created a stored procedure in mysql DELIMITER // CREATE PROCEDURE simpleproc ()
I have the MYSQL stored procedure defined as shown below: DROP PROCEDURE IF EXISTS
I've got a mySql stored procedure that looks like this-- delimiter | create procedure
I have created stored procedure in MySQL in Window-7. it run successfully on windows.
I have created a MYSQL stored procedure that searches all columns of a table
I have created few stored procedures in MySql, using the commands CREATE PROCEDURE sample()
Well I have this MySQL stored procedure that I wrote and if I run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.