class MyBean{
public long id;
public Date createTime;
}
if you execute following codeMyBean bean = new MyBean();
Date time;
bean.createTime = time;
//save and get with hibernate
save(bean);
MyBean storedBean = getBeanById(bean.id);
log.info("Times are equal: {}", storedBean.createTime.equals(time));
Variable 'time' was created and saved so that we can expect log will print "Times are equal true" but actually we'll see "Times are equal false"
When hibernate fetch Date from DB it returns java.sql.DateThat's it
If you need such condition in code you can do like this
log.info("Times are equal: {}", storedBean.createTime.getTime()==time.getTime());
//returns Times are equal true
Немає коментарів:
Дописати коментар