开发者

Update persistent object in Hibernate

I need to update an Object. I fetch it. The object is a Persistent Object. Now.. 开发者_JAVA百科If I change any properties, because is a persistent (not detached) object, any varations is immediately saved? I need to call a function? Or when session is flushed, the modification are stored?


If it is a persistent object, the changes will be saved when the session is flushed.


Regarding Chris's answer, and the followup question "how do I configure the session to close after the request": the traditional way to do this is to wrap the relevant servlets (assuming this is a web application) in a Filter that opens a session and associates it with the current thread, calls doFilter, and then either commits or rolls back the transaction based on whether an error occured. This is known as the "Open Session in View" pattern.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜