日期:2014-05-17 浏览次数:20833 次
public static List findgoods_index() {
Transaction tx = null;
List list = null;
try {
session = hib.openSession(); //调用公共类的开启session方法.
tx = (Transaction) session.beginTransaction(); //开启事物
Query query = session.createQuery("from com.hiernate.persistence.Goods "); //应用HQL检索查找满足条件的集合
list = query.list(); //list方法用来执行HQL语句
tx.commit(); //事务的提交
hib.closeSession(session); //关闭session
} catch (Exception e) {
e.printStackTrace(); //输出异常信息
tx.rollback(); //事务的回滚
}
return list;
<%
List goodslist= HibernateUtil.findgoods_index();
for(int i=0;i<goodslist.size();i++)
{
Goods goods =(Goods)goodslist.get(i);
gcode= goods.getId();
%>
<u><%=goods.getGoodsStyle()%>--<%=goods.getGoodsName()%>- -<%=goods.getStartOmit()%>- -<%=goods.getStartCity()%>- -<%=goods.getEndOmit()%>- -<%=goods.getEndCity()%> </u></a> <br/>
<%
}
%>