hibernate 简单实例出错
import org.hibernate.Transaction;public class HibernateDAOTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
EchoMessageDAO dao=new EchoMessageDAO();
Transaction tran=dao.getSession().beginTransaction();
EchoMessage bean=new EchoMessage();
bean.setMsg("Hibernate message");
dao.save(bean);
();
java.util.List<EchoMessage> results=dao.findAll();
for(int i=0;i<results.size();i++)
{
System.out.println(results.get(1));
System.out.println(results.get(2));
}
dao.getSession().close();
}
}
报错:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NullPointerException
at HibernateDAOTest.main(HibernateDAOTest.java:18)