BaseX can't add to database and query in different test
Thursday, 12 March 2015 · 2 messages · last reply 13 Mar 2015
JR
Jason Ricles12 Mar 2015 16:55 #
I am currently using BaseX for an XML database. Each XML file currently has a uuid. So, to avoid adding multiple same files to the database, have made a query that will check to see if the uuid from the file being added is already in the database. However I am not able to query the files that already exist in the database until I either open up the database in the BaseX GUI or have the query statement executed at the same time the file is added. So for example if I ran a test of adding a file to the database and then ran a test to query this file it would be unable to query this file. However If I ran the test to add the file to the database and query in the same test the query would work or if I ran the test to add the file to the database and then ran the BaseX GUI and then ran the query test the query will work correctly. Also if I already add the file to basex don't open up the DB then run to add the file again and check before I add the file the query will not work before but only after the file is added a second time. I am writing my code in java. Does anyone know why this is happening and if there is a solution?
CG
Christian Grün13 Mar 2015 12:00 #
Hi Jason,
Quoted text · Jason Ricles · 2 lines
> I am currently using BaseX for an XML database. Each XML file > currently has a uuid.
If there is not need to preserve the original file names, you could also store the UUID as filename. If you use
db:exists($db, $uuid), you will know if your file already exists.Quoted text · Jason Ricles · 3 lines
> So for example if I ran a > test of adding a file to the database and then ran a test to query > this file it would be unable to query this file.
I'm not sure if I can follow. Could you possibly provide us with the XQuery expressions you are using?
Christian
Written for BaseX 8.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery