【发布时间】:2013-04-29 11:38:39
【问题描述】:
我正在尝试将日历滚动一周并使用 Hibernate 将其持久化。滚动工作(使用 println 测试)但保存在数据库中的数据似乎是原始日历。
Calendar outDate = Calendar.getInstance();
System.out.println(outDate.getTime());
Loan loan = new Loan();
loan.setCatalogueEntry(catalogueEntry);
loan.setOutDate(outDate);
loan.setNoOfRenewals(0);
outDate.add(Calendar.WEEK_OF_YEAR, 1); //Rolling the calendar to a week further
System.out.println(outDate.getTime());
loan.setDueDate(outDate);
loan.setUser(user);
loanDao.save(loan);
catalogueEntryDao.update(catalogueEntry);
GenericHibernateDao<T, ID extends Serializable> implements GenericDao<T, ID> 类有以下方法:
@Override
public void save(T instance) {
getSessionFactory().getCurrentSession().save(instance);
}
public interface LoanDao extends GenericDao<Loan, Long> 没有任何保存方法的实现。
我的代码有什么问题?
【问题讨论】:
-
你能发布你的 println() 吗?
-
发布你的 LoadDao 和你的 hibernate.xml
-
@Daniel:请检查更新。此外,我的 sessionfactory 是通过 spring bean 实例化的,而不是 hibernate.cfg.xml 文件。
标签: java hibernate spring-mvc calendar