private OObjectDatabaseTx db;
@Before
public void before() throws Exception {
db = new OObjectDatabaseTx("memory:test");
System.out.println("db.exists(): " + db.exists());
if(!db.exists()) {
db.create();
System.out.println("db.create()");
}
System.out.println("db: " + db.getClass().getName() + "@" + Integer.toHexString(db.hashCode()));
System.out.println("db.getEntityManager(): " + db.getEntityManager());
db.getEntityManager().registerEntityClass(TestObject.class);
}
@After
public void after() throws Exception {
db.drop();
System.out.println("db.drop()");
}
@Test
public void testOne() throws Exception {
System.out.println("testOne start");
System.out.println(db.query(new OSQLSynchQuery<OUser>("select from OUser")));
System.out.println(db.query(new OSQLSynchQuery<TestObject>("select from TestObject")));
System.out.println("testOne end");
}
@Test
public void testTwo() throws Exception {
System.out.println("testTwo start");
System.out.println(db.query(new OSQLSynchQuery<OUser>("select from OUser")));
System.out.println(db.query(new OSQLSynchQuery<TestObject>("select from TestObject")));
System.out.println("testTwo end");
}
// OObjectDatabaseTx:680
protected void init() {
entityManager = OEntityManager.getEntityManagerByDatabaseURL(getURL());
...
}
// OObjectDatabaseTx:680
protected void init() {
...
entityManager.setClassHandler(OObjectEntityClassHandler.getInstance());
...
}
OObjectDatabaseTx db = new OObjectDatabaseTx("memory:A");
System.out.println("db: " + db.getClass().getName() + "@" + Integer.toHexString(db.hashCode()));
System.out.println("db.getURL(): " + db.getURL());
System.out.println("db.getEntityManager(): " + db.getEntityManager());
System.out.println("before registerEntityClass(): " + db.getEntityManager().getEntityClass(TestObject.class.getSimpleName()));
db.getEntityManager().registerEntityClass(TestObject.class);
System.out.println("after registerEntityClass(): " + db.getEntityManager().getEntityClass(TestObject.class.getSimpleName()));
OObjectDatabaseTx db2 = new OObjectDatabaseTx("memory:B");
System.out.println("db: " + db2.getClass().getName() + "@" + Integer.toHexString(db2.hashCode()));
System.out.println("db.getURL(): " + db2.getURL());
System.out.println("db.getEntityManager(): " + db2.getEntityManager());
System.out.println("before registerEntityClass(): " + db2.getEntityManager().getEntityClass(TestObject.class.getSimpleName()));
db2.getEntityManager().registerEntityClass(TestObject.class);
System.out.println("after registerEntityClass(): " + db2.getEntityManager().getEntityClass(TestObject.class.getSimpleName()));
OObjectDatabaseTx db = new OObjectDatabaseTx("memory:A");
db.create();
db.getEntityManager().registerEntityClass(TestObject.class);
System.out.println("DB - METADATA - SCHEMA - CLASSES: " + db.getURL());
for(OClass oClass : db.getMetadata().getSchema().getClasses()) {
System.out.println(oClass);
}
//db.drop();
OObjectDatabaseTx db2 = new OObjectDatabaseTx("memory:B");
db2.create();
System.out.println("DB - METADATA - SCHEMA - CLASSES: " + db2.getURL());
db2.getEntityManager().registerEntityClass(TestObject.class);
for(OClass oClass : db2.getMetadata().getSchema().getClasses()) {
System.out.println(oClass);
}
--
Thanks for the response.
I haven't tried against 1.3 snapshot I will do that today.
I was struggling with the following, all steps carried out within the same JVM
1) Create/open database1.
2) Register entity classes A,B,C in database 1.
3) Work with these entity classes, saving, loading, and querying them.
4) Close database 1.
5) Create/open database2.
6) Register entity classes A,B,C in database 2. (these being exactly the same classes that were previously registered in database1.
7) Any queries (select from A) in database2 fail with a query parse exception with an exception message telling me that the class I was querying (A) does not exist in the database. All other operations in database2 for these classes succeed - saving, loading, retrieving by ORID. And once an object has been saved, queries *do* work, they just don't work when there are no instances of the class in the database. The workaround is to look for instance count > 0 before exceuting a query but ideally that shouldn't be necessary.
I didn't want to report this until I had either found errors in my own code or found the issue reported in this group. This case is easily reproducable. When searching through this group for a similar problem I came across Mark's description which I think describes the same issue and he went further by identifying the probable cause. This thread was focusing on the issue surfacing when several junit tests are run by maven and a solution was given for maven which essentially (I think) causes a new JVM to be used for each test - which is actually more of a workaround I think and left the original problem unsolved for those who would be needing this ability to use different databases in a live situation. In my case it is absolutely normal for users to be working with different databases within one single session and one single JVM as they are building navigable indexes of different sets of documents.
As I said in my earlier post this is all occurring when using the object database.
Cheers,
Tim
--
---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.