开发者

Oracle Flashback Query with Hibernate

I've to use Oracle F开发者_StackOverflow中文版lashback Queries in my Java application. We're using Hibernate for data persistence so I'd like to know if there is a way of enable this feature in Hibernate.

Of course I can use SQL queries of Hibernate, but that's not the idea.


So far Hibernate is not supporting this functionality in a native way (as far as I know), but with the mentioned ENABLE_AT_TIME Oracle calll you will be actually able to achive what you want. Be careful though! this will enable the "time machine" for the entire session (that could lead to interesting behaviour in case of connection pooling). Here is a full example on correct usage:

EXECUTE dbms_flashback.enable_at_time('30-AUG-2000');
--your queries go here
SELECT salary FROM emp where name = 'Joe'
EXECUTE dbms_flashback.disable;

Eclipselink is something that supports ("history.as-of") the as of timestamp solution, but you have to set it as a hint. For example:

//...
query.setHint("eclipselink.AS_OF", "2012/10/15 11:21:18.2");
//...

Or you can do it via annotation:

//...
@QueryHint(name=QueryHints.AS_OF, value="2012/10/15 11:21:18.2");
//...

If you have stick to Hibernate you should take a look at the incorporated Auditing with the @Audit annotation. https://docs.jboss.org/envers/docs/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜