<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>