是否有最佳实践来显示JSP上的数据库更改 [英] Is there a best practice for showing database changes on a JSP

查看:58
本文介绍了是否有最佳实践来显示JSP上的数据库更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要在JSP页面上显示数据库更改.数据库中的信息已由旧版系统更改,因此我没有任何更改可获取有关数据更改的事件.因此,问题在于使数据库信息和JSP页面保持同步.

We need to show database changes on a JSP page. The Information in the Database is changed by a legacy System, so I don’t have any change to get an event on Data change. So the problem is to keep the Database Information and the JSP Page in sync.

我们的第一种方法是轮询数据库并将数据与Application Bean同步.如果数据已更改,我们将使用推送机制来更新JSP页面.

Our first approach is to poll the Database and synchronizing the data with an Application bean. If the data has changed, we use a push mechanism to update the JSP page.

这种方法可行,但是我不确定这是否是一种好方法.

This approach Works but somehow I am not sure if it’s a good approach.

我们正在使用MS-SQL数据库和Tomcat作为Servlet容器.

We are using a MS-SQL Database and a Tomcat as Servlet Container.

推荐答案

如果您使用的是JPA,则可以尝试使用实体侦听器和回调.方法的注释很少(例如PreRemove),可用于跟踪所需的所有更改.请参见 http://docs.jboss. org/hibernate/orm/4.0/hem/en-US/html/listeners.html

If you are using JPA you could try Entity listeners and Callbacks. There are few annotations for methods(like PreRemove) which which you can use for tracking all changes you need. See this article http://docs.jboss.org/hibernate/orm/4.0/hem/en-US/html/listeners.html

这篇关于是否有最佳实践来显示JSP上的数据库更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆