有没有类似 .NET DataView/DataSet for Java 的东西,我可以在其中快照一些数据,然后对其执行查询?
上下文
在我们的应用程序中,我们使用超级用户输入的查询从数据库中快照数据,然后使用 XML 保存该快照中的数据。如果我使用 .NET,我会使用 DataSet(+ DataTables)和 DataView,它们非常适合此目的。但我身处 Java 世界,我的冲动选择是使用 XML 存储快照数据(这可以在项目的这个阶段轻松更改)。
问题 1
是否有任何东西可以让您对数据进行快照,而无需先为 Java 平台创建其结构,就像 DataSet 为 .NET 所做的那样,并且允许稍后对该数据执行查询?我考虑过将其存储在数据库中或使用 Apache Lucene,但是对于这两种方法,我都必须管理数据库结构,但我宁愿不这样做。
问题 2
假设您有以下 XML:
<data>
<record>
<user>ravi</user>
<age>32</age>
<city>calgary</city>
</record>
<record>
<user>spiderman</user>
<age>68</age>
<city>new york</city>
</record>
</data>
并且,在该数据上,我将执行以下查询:
age > 50 or city = 'new york'
该操作的结果将是原始 XML 的子集,仅包含与条件匹配的记录在查询中。
谢谢!
Context
In our application, we snapshot data from a database using a query that is entered by a super user, and then we save the data from that snapshotting using XML. If I was using .NET, I would use a DataSet (+ DataTables) and DataViews, which are pretty good for that purpose. But I am in the Java world, and my impulse choice was to store the snapshotted data using XML (this can be easily changed at this phase of the project).
Question 1
Is there anything that allows you to snapshot data without having to create its structure first for the Java platform, like a DataSet would do for .NET, and that would allow to perform queries on that data later? I thought about storing it in the database or using Apache Lucene, but for both approaches I would have to manage the database structure, which I would prefer not doing.
Question 2
Supposed you have the following XML:
<data>
<record>
<user>ravi</user>
<age>32</age>
<city>calgary</city>
</record>
<record>
<user>spiderman</user>
<age>68</age>
<city>new york</city>
</record>
</data>
And, on that data, I would execute the following query:
age > 50 or city = 'new york'
The result of that operation would be a subset of the original XML only with the records that match the conditions in the query.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个有点类似的东西,称为
RowSet
,它是 JDBC 规范的一部分。您可以获取数据并将其缓存在CacheRowSet
您可以稍后操作甚至更新。似乎还有一个FilteredRowSet
,这样您就可以创建只显示您想要的数据的视图。这看起来与 ADO.NET
DataView
和DataSet
比较相似。另请注意,RowSet
在 Java 地区并不流行。更多提示:
There is something a bit similar called a
RowSet
, which is part of the JDBC spec. You can get data and cache them in aCacheRowSet
that you can manipulate or even update later. Seems like there is also aFilteredRowSet
, so that you can create view that shows only the data you want.This looks relatively similar to ADO.NET
DataView
andDataSet
. Note also thatRowSet
are not popular in Javaland.A few more pointers: