1

For persisting data used hibernate with SQLServer. In system every table contains four column.

1. Created User
2. Created Date
3. Modified User
4. Modified Date

From beginning system does not contain any mechanism for entering "modified User" and "modified Date" while insert and update operation.

My Question. is there any way in hibernate to entering modified User and Modified Date without changing every where ?

My question:

1)Is there any way to provide user(inform of Id or bean) to hibernate ?

2)If Yes,How can I tell to hibernate that populate this two columns while doing insert of records?

Thanks for any help.

4

1 回答 1

1

一种方法是更改​​您的 servlet、rest 控制器或您正在编写的 DAO。

第二种方法是创建一个 DAO、servlet 或 rest 控制器来获取用户对象和日期,并使您的所有 servlet/daos/controllers 扩展您刚刚创建的那个。

这是一个痛苦的背后,但它会比设置一个单一的上下文更好。

将安全上下文(用户)和日期传递给 DAO 非常容易,并且将来维护起来会容易得多。

于 2013-09-06T05:35:04.700 回答