Package dev.grafeo.gwp
Class GqlSession
java.lang.Object
dev.grafeo.gwp.GqlSession
- All Implemented Interfaces:
AutoCloseable
An active session with a GWP server.
Implements AutoCloseable for use with try-with-resources.
try (GqlConnection conn = GqlConnection.connect("localhost:50051")) {
try (GqlSession session = conn.createSession()) {
ResultCursor cursor = session.execute("MATCH (n) RETURN n");
for (List<Object> row : cursor) {
System.out.println(row);
}
}
}
-
Method Summary
Modifier and TypeMethodDescriptionBegin a new read-write transaction.beginTransaction(boolean readOnly) Begin a new transaction.voidclose()Close the session.Execute a GQL statement.Execute a GQL statement with parameters.longping()Ping the server.voidreset()Reset session state to defaults.The session identifier.voidSet the current graph for this session.voidSet the current schema for this session.voidsetTimeZone(int offsetMinutes) Set the session timezone as a UTC offset in minutes.
-
Method Details
-
sessionId
The session identifier. -
execute
Execute a GQL statement.- Parameters:
statement- the GQL statement to execute- Returns:
- a cursor over the results
-
execute
Execute a GQL statement with parameters.- Parameters:
statement- the GQL statement to executeparameters- named parameters (may be null)- Returns:
- a cursor over the results
-
beginTransaction
Begin a new read-write transaction.- Returns:
- the new transaction
-
beginTransaction
Begin a new transaction.- Parameters:
readOnly- true for a read-only transaction- Returns:
- the new transaction
-
setGraph
Set the current graph for this session.- Parameters:
name- the graph name
-
setSchema
Set the current schema for this session.- Parameters:
name- the schema name
-
setTimeZone
public void setTimeZone(int offsetMinutes) Set the session timezone as a UTC offset in minutes.- Parameters:
offsetMinutes- the UTC offset in minutes (e.g. 60 for UTC+1)
-
reset
public void reset()Reset session state to defaults. -
ping
public long ping()Ping the server. Returns a server timestamp.- Returns:
- the server timestamp
-
close
public void close()Close the session. Rolls back any active transaction on the server side.- Specified by:
closein interfaceAutoCloseable
-