冬眠和春季框架的初学者。 我想使用冬眠模板插入数据库。 我的 DAO 代码 :
public void save(News transientInstance) {
log.debug("saving News instance");
try {
save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
主计长
public void insert(NewsForm newsForm, RequestContext context) {
NewsDAO NewsDAO = (NewsDAO) ApplicationContext.getApplicationContext().getBean("NewsDAO");
News newNews = new News();
Timestamp date = new Timestamp(System.currentTimeMillis());
newNews.setDate(date);
newNews.setTitle(newsForm.getTitle());
newNews.setDescription(newsForm.getDescription());
newNews.setBody(newsForm.getBody());
newNews.setStatus(newsForm.getStatus());
newNews.setUpdateDate(date);
NewsDAO.save(newNews);
}
错误是错误
Caused by: java.lang.StackOverflowError
at org.apache.commons.logging.impl.Log4JLogger.debug(Log4JLogger.java:177)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68)
dao.NewsDAO.save(NewsDAO.java:68) ...etc
这是DAO代码错误吗?