-
Notifications
You must be signed in to change notification settings - Fork 872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database closed #3678
Milestone
Comments
It seems that one of the quickest way to release a OrienDatabase from pool without releasing it it's the following:
It sounds a bit strange but works. |
Test Case: package it.celi.cbook.temp;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.BeforeClass;
import org.junit.Test;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
public class OrientCloseDatabaseTest {
private static OrientGraphFactory pool;
@BeforeClass
public static void setup() {
createGraph();
pool = new OrientGraphFactory("memory:temp", "admin", "admin").setupPool(1, 10);
try(ODatabaseDocumentTx db = pool.getDatabase()) {
OrientGraph graph = new OrientGraph(db);
fillTheGraph(graph);
}
}
private static void createGraph() {
OrientGraph g = new OrientGraph("memory:temp", "admin", "admin");
g.shutdown();
}
private static void fillTheGraph(OrientGraph graph) {
OrientVertex riccardo = createPerson(graph, "riccardo", 32);
OrientVertex luca = createPerson(graph, "luca", 40);
OrientVertex luigi = createPerson(graph, "luigi", 30);
OrientVertex milano = createCity(graph, "milano", 1332516);
OrientVertex roma = createCity(graph, "roma", 1332516);
OrientVertex unknown = createCity(graph, "unknown", -1);
riccardo.addEdge("lives", milano);
luca.addEdge("lives", roma);
luigi.addEdge("lives", unknown);
}
private static OrientVertex createPerson(OrientGraph graph, String localName, int age) {
OrientVertex a = graph.addVertex("class:Person");
a.setProperties(
"localName", localName,
"age", age
);
return a;
}
private static OrientVertex createCity(OrientGraph graph, String localName, int population) {
OrientVertex a = graph.addVertex("class:City");
a.setProperties(
"localName", localName,
"population", population
);
return a;
}
@Test
public void test1() {
try (ODatabaseDocumentTx db = pool.getDatabase()) {
String queryText = "SELECT @rid as rid, localName FROM Person WHERE ( 'milano' IN out('lives').localName OR 'roma' IN out('lives').localName ) ORDER BY age ASC";
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryText);
List<ODocument> results = db.query(query);
assertNotNull(results);
assertThat(results.size(), Matchers.greaterThan(0));
}
}
@Test
public void test2() {
try (ODatabaseDocumentTx db = pool.getDatabase()) {
String queryText = "SELECT @rid as rid, localName FROM Person WHERE age > 30";
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryText);
List<ODocument> results = db.query(query);
assertNotNull(results);
assertThat(results.size(), Matchers.greaterThan(0));
}
}
} |
tglman
added a commit
that referenced
this issue
Mar 4, 2015
fixed on hotfix branch, leaving open till the fix is ported to develop |
Can you just cherry-pick it? |
yes, but we have some issue with the new sql parser that i prefer will be fixed before |
tglman
added a commit
that referenced
this issue
Mar 5, 2015
Conflicts: graphdb/src/main/java/com/orientechnologies/orient/graph/sql/OCommandExecutorSQLDeleteEdge.java
merged in develop closing |
Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue from Riccardo Tasso:
Hi, I am migrating my application to Orient 2.0.3, from 1.7.10.
I have a UnitTest which throws an Exception, and I can't figure out why. Here is the stacktrace:
The problem seems to be that I'm executing a query over a closed database. Anyway it should not be closed, since it's a pool.
The strange thing is also that with another query (test2) which doesn't involve edges, the exception is not thrown.
Am I using the API in a wrong way?
Looking at documentation ( http://www.orientechnologies.com/docs/last/orientdb.wiki/Graph-Factory.html ) everything seems ok.
The text was updated successfully, but these errors were encountered: