I have a situation that I would like to understand better :) (this mail is
to every sedna user, not just to Charles Foster because he wrote XML:DB API)
:)

I execute the following commands in a newly created database (database is
named "basic") :
CREATE COLLECTION "locked"

LOAD "books.xml" "books.xml" "locked"

(Collection can be named anything and "books.xml" can be any type of file)

Using the XML:DB API I have the following class (skip the class code, and
check my explanation, comeback later to see what it does)


import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.modules.TransactionService;
import org.xmldb.api.modules.XMLResource;

public class ManySessions
{
public static void main(String[] args) throws Exception
{

org.xmldb.api.base.Database dbDriver =
(org.xmldb.api.base.Database)Class.forName("net.cfoster.sedna.DatabaseImpl").newInstance();

DatabaseManager.registerDatabase(dbDriver);


org.xmldb.api.base.Database sednaDatabase;
Class clazz = Class.forName("net.cfoster.sedna.DatabaseImpl");
sednaDatabase = (org.xmldb.api.base.Database)(clazz.newInstance());

Collection col =
DatabaseManager.getCollection("xmldb:sedna://localhost:5050/basic","SYSTEM","MANAGER").getChildCollection("locked");


TransactionService service = (TransactionService)
col.getService("TransactionService", "1.0");

   service.begin();

XMLResource
resource=(XMLResource)col.createResource("locker.xml",XMLResource.RESOURCE_TYPE);

resource.setContent("<test>Text</test>");
col.storeResource(resource);
System.out.println("Go to Sleep");
Thread.sleep(30000);
System.out.println("Awake from Sleep");

//Commit
service.commit();
col.close();
 }}

This class basically begins a transaction, inserts the "locker.xml" document
in the "locked" collection and then sleeps for 30 seconds, before committing
the transaction.
I execute the ManySessions class and when the "Go to Sleep" message appears,
I go to the command line and execute

se_term -file new.xquery basic

Where the contents of "new.xquery" are:
let $m := document("books.xml","locked") return $m

The result is that se_term "hangs" waiting for the Java Class to commit the
transaction.


My question is.... is it supposed to "lock" the entire collection when
storing a resource (inside a transaction)? Am I doing something wrong?
I had a problem of dead-lock when trying to write and read the same
document, but in this situation I'm storing document A and reading from
document B in the same
collection.

I have tried, without the Thread.sleep (making multiple inserts to take
time) and connecting with different users, but same result.

How can I resolve this situation?

Another thing I'm interested.... I've tried using the metacommands in
se_term but the execution always fails giving me a syntax error, even when
running
the example in the documentation (executing from a xquery file) :

\nac
CREATE DOCUMENT "test"&
UPDATE INSERT <test>{"test"}</test> INTO fn:doc("test")&
fn:doc("test")&
\commit


SEDNA Message: ERROR XPST0003
It is a static error if an expression is not a valid instance of the grammar
def
ined in A.1 EBNF.
Details: at (7:1), unexpected symbol: '\'
at (7:1), syntax error, unexpected lexical error
at (8:23), unexpected symbol: '&'
at (9:29), syntax error, unexpected </, expecting end of file or statem
ent separator

What am I doing wrong?

Many thanks in advance for any help you can give =)



-- 
Pedro Pereira
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Sedna-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to