I have to use an xml database (Sedna) to store and retrieve Java objects. Every custom class in the project is stored into a collection. I have the following problem : I'm not sure how the objects are written into the collection. That is to say, I don't know their exact xml structure, so I can't do a proper query on them.
Is there a query that, for a given collection, will show me the content of a collection?
Host h = new Host();
h.name = "test1";
h.freeSpace = 32;
String id1 = this.addHost(h);
//addHost method
try
{
Collection c = this.findCollection("Hosts"); //gives me the Hosts collection
if (c == null)
return null;
h.id = c.createId();
BinaryResource br = (BinaryResource) c.createResource(h.id, BinaryResource.RESOURCE_TYPE);
br.setContent(h);
c.storeResource(br);
return h.id;
} catch (XMLDBException e) {
System.err.println("Error adding Host entry into the database: " + e.getMessage());
return null;
}
To view structure (schema) of your database or collection or document query one of the following system documents (Retrieving Metadata):
$schema
– descriptive schema of all documents and collections with some schema-related information;$schema_<name>
– the descriptive schema of the document or collection named ;For example, run
se_term
, and executedoc('$schema_test')
to get structure of the 'test' document/collection.How do you store your resources? Please give us snippet of code. It's very hard to understand even which one API do you use (XML:DB, XQJ, native Sedna Java API).