Hibernate打出执行语句,怎么还是没有插入数据呢,也没有异常,这怎么解释呢?
public static void main(String[] agrs) {
Session session = null;
try{
session = HibernateSessionFactory.getSession();
News news = new News();
news.setAddtime(new Date());
news.setNewscontent("aaa");
news.setTitle("bbb");
session.save(news);
} catch(Exception e) {
e.printStackTrace();
} finally{
session.close();
}
}
Hibernate: insert into bookstore.news (title, newscontent, addtime) values (?, ?, ?)
------解决方案--------------------
没有commit,
session.save(news);
session.commit;
你试试,好久没有写过了