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!
There is something a bit similar called a
RowSet, which is part of the JDBC spec. You can get data and cache them in aCacheRowSetthat 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
DataViewandDataSet. Note also thatRowSetare not popular in Javaland.A few more pointers: