您的位置:首页 > 产品设计 > UI/UE

id to load is required for loading 原因?

2014-07-24 23:27 423 查看
<span style="font-size:18px;"><strong>public Street findById(Integer id) {
// TODO Auto-generated method stub
Session session=HibernateUtil.getSession();
//System.out.println(session);
Transaction tx=session.beginTransaction();
Street d=null;
try{
d=(Street)session.get(Street.class,id);

System.out.println(d);

tx.commit();</strong></span>
我的这几行代码出错了,想了半天才想出来,原来
<span style="font-size:18px;"><strong>Integer id——》</strong></span><span style="font-size:18px;"><strong>Street.class,id</strong></span><span style="font-size:18px;"><strong>
原来是我没对应上来,上面代码就是标准代码,我是把id写成了d,所以取出来的总是null

</strong></span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  id to load is requir