views:

39

answers:

1

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!

+1  A: 

There is something a bit similar called a RowSet, which is part of the JDBC spec. You can get data and cache them in a CacheRowSet that you can manipulate or even update later. Seems like there is also a FilteredRowSet, so that you can create view that shows only the data you want.

This looks relatively similar to ADO.NET DataView and DataSet. Note also that RowSet are not popular in Javaland.

A few more pointers:

ewernli
Yes, I came across that interface, but found no concrete implementations of it...
Ravi Wallau
I've added links to the reference implementation
ewernli
The last link may solve my problem. I will try it out - and then accept the answer. I was just thinking if there would be anything else... Thanks!
Ravi Wallau
@ewernli It seems those are the only options I have... I agree with you, it seems that RowSet is really not popular in Javaland. I may end up with something else.
Ravi Wallau