sessionFactory.getCurrentSession() 为空
Query query = sessionFactory.getCurrentSession().createQuery总是抱错,
Exception in thread "main" java.lang.NullPointerException
at com.corona.web.action.SaveTrouble1Action.main(SaveTrouble1Action.java:354)
请问如何是sessionFactory.getCurrentSession()有效,谢谢。
//----------------------------------------------------------
public static void main(String args[]){
String id = null;
List list = new ArrayList();
Query query = sessionFactory.getCurrentSession().createQuery(
"select plcIP from PlcAmsNetID where wind_Code = ? " );
list = query.setParameter(0, "1").list();
if(list.size() > 0 ){
id = (String)list.get(0);
}
System.out.println("id >>>" + id);
}