Current Vertex is not persistent Exception: IllegalArgumentException #1100
-
How do I make vertexes persistent? I'm currently running from the https://docs.arcadedb.com/#_create-a-graph Java API example. [To redirect Truffle log output to a file use one of the following options:
* '--log.file=<path>' if the option is passed using a guest language launcher.
* '-Dpolyglot.log.file=<path>' if the option is passed using the host Java launcher.
* Configure logging using the polyglot embedding API.]
[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
The guest application code will therefore be executed in interpreted mode only.
Execution only in interpreted mode will strongly impact the guest application performance.
For more information on using GraalVM see https://www.graalvm.org/java/quickstart/.
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.
Exception in thread "main" java.lang.IllegalArgumentException: Current vertex is not persistent
at com.arcadedb.graph.GraphEngine.newEdge(GraphEngine.java:114)
at com.arcadedb.graph.MutableVertex.newEdge(MutableVertex.java:130)
at jmh.Test35_2_2.main(Test35_2_2.java:29) DatabaseFactory databaseFactory = new DatabaseFactory("/databases/mydb");
Database database = databaseFactory.open();
// database.command("sql", "create vertex type User");
// MutableVertex elon = db.newVertex("User", "name", "Elon", "lastName", "Musk");
MutableVertex elon = database.newVertex("User");
elon.set("name", "Elon").set("lastName", "Musk");
// MutableVertex steve = db.newVertex("User", "name", "Steve", "lastName", "Jobs");
MutableVertex steve = database.newVertex("User");
elon.set("name", "Steve").set("lastName", "Jobs");
elon.newEdge("IsFriendOf", steve, true, "since", 2010);
database.close(); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
How do I make vertex-RIDs for these vertices? public MutableEdge newEdge(String edgeType, Identifiable toVertex, boolean bidirectional, Object... properties) {
return this.database.getGraphEngine().newEdge(this, edgeType, toVertex, bidirectional, properties);
} public MutableEdge newEdge(final VertexInternal fromVertex, String edgeTypeName, final Identifiable toVertex, final boolean bidirectional,
final Object... edgeProperties) {
// ...
final RID fromVertexRID = fromVertex.getIdentity();
if (fromVertexRID == null)
throw new IllegalArgumentException("Current vertex is not persistent"); public interface Record extends Identifiable {
RID getIdentity(); |
Beta Was this translation helpful? Give feedback.
-
Thanks again Luca! import com.arcadedb.database.Database;
import com.arcadedb.database.DatabaseFactory;
import com.arcadedb.graph.MutableVertex;
import com.opencsv.exceptions.CsvValidationException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
public class Test {
private static final Logger logger = LogManager.getLogger(Test35_2_2.class);
public static void main(String[] args) throws IOException, CsvValidationException {
DatabaseFactory databaseFactory = new DatabaseFactory("/databases/mydb");
Database database = databaseFactory.open();
database.begin();
// database.command("sql", "create vertex type User");
// MutableVertex elon = db.newVertex("User", "name", "Elon", "lastName", "Musk");
MutableVertex elon = database.newVertex("User");
elon.set("name", "Elon").set("lastName", "Musk").save();
// MutableVertex steve = db.newVertex("User", "name", "Steve", "lastName", "Jobs");
MutableVertex steve = database.newVertex("User");
steve.set("name", "Steve").set("lastName", "Jobs").save();
// database.command("sql", "create edge type IsFriendOf");
elon.newEdge("IsFriendOf", steve, true, "since", 2010);
database.commit();
database.close();
}
} |
Beta Was this translation helpful? Give feedback.
Thanks again Luca!