Hibernate HQL不执行也不抛出异常
public Course getCourse(int cid){
Session session = null;
Transaction tx = null;
List l = null;
Course ct =null;
try{
session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();
System.out.println(1111111112);
Query query = session.createQuery("from Course course where CId =?");
System.out.println(111111111);
query.setParameter(0, cid);
ct=(Course) query.uniqueResult();
query = null;
tx.commit();
}catch(Exception e)
{
e.printStackTrace();
System.out.print(e.getMessage());
}finally
{
if(tx!=null)
tx.rollback();
HibernateSessionFactory.closeSession();
}
return ct;
}
------解决方案--------------------Query query = session.createQuery("from Course course where
course.CId =?");
------解决方案--------------------好像是这一句的问题。。。session = HibernateSessionFactory.currentSession();