<sql-query name="queryPro2" callable="true"> <!-- alias: 查询返回的对象的别名, 随便取 class 查询返回的类的全路径,否则会抱找不到类的错误 --> <return alias="TableTest" class="com.test.hibernate.TableTest"> <return-property name="id" column="id" /> <return-property name="name" column="name" /> <return-property name="value" column="value" /> </return> {call queryProV(?)} </sql-query> </hibernate-mapping> 4.3. 使用 package com.test.dao; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import com.test.hibernate.HibernateSessionFactory; import com.test.hibernate.TableTest; public class TestDao { /** * 无参数的hibernate 存储过程查询 */ public void query(){ Session session=null; try{ session=HibernateSessionFactory.getSession(); Query qy=session.getNamedQuery("queryPro1"); List<TableTest> list=qy.list(); if(list!=null){ |