在DBMS中处理完整历史记录的最佳设计(Best design for handling complete history in a DBMS)
我正在开发一个带有多个实体和关系的DBMS的网站。 我希望网站的用户能够查看某些内容中已更改内容的完整历史记录,例如,何时,由谁以及字段已更改为什么。
到目前为止,我已经考虑使用链表方法,您只需持久而不是更新实体,并将ID保存到上一个实体。 但是,由于关系可能会发生变化,因此我不知道上次更新时链接实体的情况。 我的意思是关系可以改变:假设我有一个Person实体,它与另一个Person实体有连接。 如果我只保留另一个人的ID,我不知道其他人员字段是否已被更新,例如,如果另一个人例如更改了其名称字段。 请参阅下文以进一步了解情况。
另一个方法可能是顺序保存对数据库的每个更改,并简单地恢复到给定的更改,例如保存所有的sql查询。
有谁知道处理这个问题的正确方法? 提前致谢。
更新
假设我有一个名为Person的实体(见下文)。 这个人可以有很多父母和孩子。 让我们说用户可以更新现有Person中的值。 每当用户例如更新名称字段时,我想保存此更改,以便其他用户可以根据需要还原更改。 如上所述,如果我只持有父母的身份证,我不知道有这个身份证的人是否有所改变。 例如,如果父母名称已更新。
Person { int id; String name; List<Person> parents; List<Person> children; }
总之:我需要在更新时显示此Person实体的列表。 在这个列表中,我需要查看Persons字段确实包含的内容,以及其父母和孩子如何查看给定更改的时间。
I am developing a website with a DBMS with several entities and relationships. I want users of the website to be able to view a complete history of what has been changed in certain entites, e.g. when, by whom and what a field has been changed to.
So far I have considered to use a linked list approach where you simply persist rather than update an entity, and keep an ID to the previous entity. However, since relationships can change, I will not know how the linked entity was at the time of the previous update. What I mean by relationships can change: Say I have a Person entity which has a connection to another Person entity. If I only hold on to the ID of the other Person, I cannot know if the other Persons fields have been updated, e.g. if the other Person has for example changed its name field. Please see below for further explenation.
Another approache might be to sequentially save every change to the database, and simply revert back to a given change, e.g. save every sql query ever made.
Does anyone know a proper way to handle this? Thanks in advance.
Update
Lets say I have an entity which is called Person (see below). The Person can have many parents and children. Lets also say a user can update values in a existing Person. Whenever a user for example updates the name field, I want to save this change, so other users can revert the change, if desired. As mentioned, if I only hold on to the ID of the parent, I cannot know wether the Person with that ID has changed or not. For example if the parents name was updated.
Person { int id; String name; List<Person> parents; List<Person> children; }
In conclusion: I need to display a list of this Person entity for whenever it has been updated. In this list I need to see what the Persons fields did contain, but also how its parents and children looked at the time of the given change.
原文:https://stackoverflow.com/questions/46749691
最满意答案
查看RESTRequest.php的代码,有两种情况会抛出此异常:
- 返回带有未知错误代码的JSON结果集(未知含义与200 OK不同)
- 根本没有返回JSON结果集
所以我怀疑连接不正常。 要了解更多信息,您应该在代码中捕获异常并对其进行评估:
它可能看起来像这样(我对Java更熟悉):
try { $d = new Client( "http://jasper.server.com/jasperserver-pro", "username", "password", "organization" ); $info = $d->serverInfo(); } catch (RESTRequestException $e) { echo 'RESTRequestException:'; echo 'Exception message: ', $e->getMessage(), "\n"; echo 'Set parameters: ', $e->parameters, "\n"; echo 'Expected status code:', $e->expectedStatusCodes, "\n"; echo 'Error code: ', $e->errorCode, "\n"; }
如果仍有错误,您可以检查以下内容:
- 您可以从部署此代码的服务器访问jasper服务器吗? 有时例如防火墙设置会干扰。
- 组织的调用是否与服务器中组织属性中的定义完全相同? (打开存储库/右键单击organization / properties / resource-id)
Looking into the code of RESTRequest.php there are two cases in which this exception is thrown:
- A JSON result set with an unknown error code is returned (unknown meaning different from 200 OK)
- No JSON result set is returned at all
So I suspect the connection isn't working properly. To find out more, you should catch the exception in your code and evaluate it:
It could look something like this (I'm more familiar with Java):
try { $d = new Client( "http://jasper.server.com/jasperserver-pro", "username", "password", "organization" ); $info = $d->serverInfo(); } catch (RESTRequestException $e) { echo 'RESTRequestException:'; echo 'Exception message: ', $e->getMessage(), "\n"; echo 'Set parameters: ', $e->parameters, "\n"; echo 'Expected status code:', $e->expectedStatusCodes, "\n"; echo 'Error code: ', $e->errorCode, "\n"; }
If there is still an error, you can check the following:
- Can you reach the jasper server from the server where this code is deployed? Sometimes e.g. firewall settings can interfere.
- Is the organization called exactly like defined in the properties of the organization in the server? (Open repository / right click on organization / properties / resource-id)
相关问答
更多-
此类位于jasper报表服务器分发中,而不是常规jasper报表分发中 JasperReports的服务器/版本 你会在war文件中找到它jasperserver.war\WEB-INF\lib\jasperserver-api-metadata-6.2.0.jar\ This class is in the jasper report server distribution, not in the regular jasper report distribution jasperreports-serve ...
-
用Gradle编译JasperReports获取不受支持的版本错误(Compile JasperReports with Gradle gets unsupported version error)[2024-02-21]
我用蚂蚁块中的以下代码打印所有的蚂蚁属性。 ant { for (o in properties) println o ... .. . } 虽然我将gradle.properties文件中的org.gradle.java.home值设置为1.6,但我发现该gradle以某种方式使用系统默认java作为java.endoresed.dir属性。 java.endorsed.dirs =的/ usr /爪哇/ jdk1.7.0_51 / JRE / LIB / ... -
查看RESTRequest.php的代码,有两种情况会抛出此异常: 返回带有未知错误代码的JSON结果集(未知含义与200 OK不同) 根本没有返回JSON结果集 所以我怀疑连接不正常。 要了解更多信息,您应该在代码中捕获异常并对其进行评估: 它可能看起来像这样(我对Java更熟悉): try { $d = new Client( "http://jasper.server.com/jasperserver-pro", "username", "pas ...
-
如何通过JasperReports Scriptlet显示用户错误消息?(How to show user error message through JasperReports Scriptlet?)[2023-03-20]
抛出JSShowOnlyErrorMessage而不是JRScriptletException 。 它是JasperReport Server库jar的一部分。 我对Jasper在文档方面感到非常失望,但最后我的同事设法找到了这个。 如果需要花费大量时间来挖掘代码以找到这样的信息,那将是非常令人沮丧的。 Throw JSShowOnlyErrorMessage instead of JRScriptletException. It is part of JasperReport Server library ... -
如何在JasperReports Server 4.0.0中配置邮件服务器设置(How to configure mail server settings in JasperReports Server 4.0.0)[2022-04-24]
雅虎设置是: Yahoo! Mail SMTP server address: smtp.mail.yahoo.com Yahoo! Mail SMTP user name: full email address (including "@yahoo.com") Yahoo! Mail SMTP password: Your Yahoo! Mail password Yahoo! Mail SMTP port: 25 所以它会是: # This file is now just a pass-throug ... -
这可能是由于某些本地HTTP代理设置问题。 要解决此问题,您可以尝试以下方法: Window->Preferences->General->Network Connections-> Provider: Manual (应用Eclipse代理设置) ( 根据需要调整代理规则 )(尝试包含/排除与您的jasper服务器主机匹配的规则) 重启Eclipse ( 重要! ) 我发现这个解决方案有点隐藏在这里: Jasper论坛问题3143评论16。 This may likely be due to some l ...
-
好吧,正如我所说,我将下载的zip文件夹中的jar(如问题中所示)添加到我的项目中并解决了我遇到的所有问题,我将lib文件夹中的下一个jar添加到我的项目中: JasperReports 5.6.0 - ... ...poi-3.7-20101029.jar ...commons-beanutils-1.8.0.jar ...commons-collections-3.2.1.jar ...commons-digester-2.1.jar ...commons-javaflow-20060411.jar . ...
-
我修好了。 我仍然不知道为什么它在服务器之前没有工作,而在localhost它做了。 无论如何,我在Reportes.java改变了crearPDF(...)这个: Session session = HibernateUtil.getSessionFactory().getCurrentSession(); 通过: Session session = HibernateUtil.getSessionFactory().openSession(); 在函数结束时,我在finally块中调用了sessio ...
-
我将数据源更改为JNDI,它运行良好。 I changed the datasource to JNDI and it worked perfectly.
-
这样这个问题有一个答案: 我的解决方案是修改我的SQL查询以在一个查询中返回我的所有数据并删除子报告。 对于一个相当重要的功能来说,这似乎是一个愚蠢的工作,但它同时工作。 Just so that this question has an answer: My solution was to modify my SQL query to return all my data in one query and remove the sub-report. This seems like a silly wor ...