我注意到,使用简单的select调用服务方法会在数据库中更新MyDomain.class日期字段(清除时间)。但是,使用@Transactional(readOnly = true)括起该方法并不会更新日期值。
为什么要将值保存到DB中?
下面是服务方法
@Transactional(readOnly = true)
Date getDate()
{
Date date = null
date = MyDomain.executeQuery("select min(s.startDate) from MyDomain s where ....)[0]
print "Result: " + date
}发布于 2012-10-14 01:42:00
仅当对象在进入hibernate会话(选中)之后和会话关闭之前(通常在方法结束时)以某种方式发生更改时,它才会在数据库中更新。看一看你的对象,看看它可能会以某种你不想要的方式被修改。
https://stackoverflow.com/questions/12874995
复制相似问题