UltipaDocs
Try Playground
  • Introduction
    • Quick Start
    • Configuration
    • Connection and Session
    • Executing Queries
    • Graph Management
    • Transactions
    • Data Operations
    • Bulk Import
    • Data Export
    • Health and Administration
    • Response Processing
    • Data Types
    • Error Handling
    • Quick Start
    • Configuration
    • Connection and Session
    • Executing Queries
    • Graph Management
    • Transactions
    • Data Operations
    • Bulk Import
    • Data Export
    • Health and Administration
    • Response Processing
    • Data Types
    • Error Handling
    • Quick Start
    • Configuration
    • Connection and Session
    • Executing Queries
    • Graph Management
    • Transactions
    • Data Operations
    • Bulk Import
    • Data Export
    • Health and Administration
    • Response Processing
    • Data Types
    • Error Handling
    • Quick Start
    • Configuration
    • Connection and Session
    • Executing Queries
    • Graph Management
    • Transactions
    • Data Operations
    • Bulk Import
    • Data Export
    • Health and Administration
    • Response Processing
    • Data Types
    • Error Handling
  1. Docs
  2. /
  3. Ultipa Drivers
  4. /
  5. Java

Data Types

The GQLDB Java driver supports a comprehensive set of data types for storing and querying graph data. This guide covers property types, enums, and type conversions.

Property Types

The PropertyType enum defines all supported data types:

Java
import com.gqldb.types.PropertyType;

Numeric Types

TypeDescriptionJava Type
INT3232-bit signed integerInteger
UINT3232-bit unsigned integerLong
INT6464-bit signed integerLong
UINT6464-bit unsigned integerLong
FLOAT32-bit floating pointFloat
DOUBLE64-bit floating pointDouble
DECIMALArbitrary precision decimalGqldbDecimal

String Types

TypeDescriptionJava Type
STRINGVariable-length stringString
TEXTLong textString

Boolean and Null

TypeDescriptionJava Type
BOOLBoolean valueBoolean
NULLNull valuenull
UNSETUnset/unknown typenull

Binary

TypeDescriptionJava Type
BLOBBinary databyte[]

Date and Time Types

TypeDescriptionJava Type
TIMESTAMPUnix timestamp with nanosecondsjava.time.Instant
DATETIMEDate and time (deprecated)java.time.Instant
DATEDate onlyjava.time.LocalDate
LOCAL_DATETIMELocal date and timeGqldbLocalDateTime
ZONED_DATETIMEDate and time with timezoneGqldbZonedDateTime
LOCAL_TIMELocal time of dayGqldbLocalTime
ZONED_TIMETime with timezoneGqldbZonedTime

Duration Types

TypeDescriptionJava Type
YEAR_TO_MONTHYear-month durationYearToMonth
DAY_TO_SECONDDay-second durationDayToSecond

Geospatial Types

TypeDescriptionJava Type
POINT2D geographic pointPoint
POINT3D3D pointPoint3D

Collection Types

TypeDescriptionJava Type
LISTOrdered listList<?>
SETUnordered unique setSet<?>
MAPKey-value mapMap<String, ?>
VECTORNumeric vectorVector

Graph Types

TypeDescriptionJava Type
NODEGraph nodeGqldbNode
EDGEGraph edgeGqldbEdge
PATHGraph pathGqldbPath

PropertyType Enum

Java
public enum PropertyType {
    UNSET,
    INT32, UINT32, INT64, UINT64,
    FLOAT, DOUBLE,
    STRING, TEXT,
    DATETIME, TIMESTAMP,
    BLOB,
    POINT, POINT3D,
    DECIMAL,
    LIST, SET, MAP,
    NULL, BOOL,
    LOCAL_DATETIME, ZONED_DATETIME,
    DATE, ZONED_TIME, LOCAL_TIME,
    YEAR_TO_MONTH, DAY_TO_SECOND,
    RECORD, VECTOR, TABLE, PATH,
    ERROR, NODE, EDGE
}

Graph Type Enum

Java
public enum GraphType {
    OPEN,      // Schema-less graph
    CLOSED,    // Schema-enforced graph
    ONTOLOGY   // Ontology-enabled graph
}

Health Status Enum

Java
public enum HealthStatus {
    UNKNOWN,
    SERVING,
    NOT_SERVING,
    SERVICE_UNKNOWN
}

Cache Type Enum

Java
public enum CacheType {
    ALL,
    AST,
    PLAN
}

Type Classes

Node Types

Java
// Data for inserting nodes
public class NodeData {
    public NodeData(String id, List<String> labels, Map<String, Object> properties);
    String getId();
    List<String> getLabels();
    Map<String, Object> getProperties();
}

// Node from query results
public class Node {
    String getId();
    List<String> getLabels();
    Map<String, Object> getProperties();
}

// Internal node representation
public class GqldbNode {
    String getId();
    List<String> getLabels();
    Map<String, Object> getProperties();
}

Edge Types

Java
// Data for inserting edges
public class EdgeData {
    public EdgeData(String id, String label, String fromNodeId,
                    String toNodeId, Map<String, Object> properties);
    String getId();
    String getLabel();
    String getFromNodeId();
    String getToNodeId();
    Map<String, Object> getProperties();
}

// Edge from query results
public class Edge {
    String getId();
    String getLabel();
    String getFromNodeId();
    String getToNodeId();
    Map<String, Object> getProperties();
}

Path Type

Java
public class Path {
    List<Node> getNodes();
    List<Edge> getEdges();
}

public class GqldbPath {
    List<GqldbNode> getNodes();
    List<GqldbEdge> getEdges();
}

Geospatial Types

Java
public class Point {
    public Point(double latitude, double longitude);
    double getLatitude();
    double getLongitude();
}

public class Point3D {
    public Point3D(double x, double y, double z);
    double getX();
    double getY();
    double getZ();
}

Duration Types

Java
public class YearToMonth {
    public YearToMonth(int months);
    int getMonths();
}

public class DayToSecond {
    public DayToSecond(long nanos);
    long getNanos();
}

Vector Type

Java
public class Vector {
    public Vector(float[] values);
    float[] getValues();
    int getDimension();
}

TypedValue

The driver uses TypedValue internally for type-safe data transfer:

Java
import com.gqldb.types.TypedValue;
import com.gqldb.types.PropertyType;

// Get typed values from a row
Row row = response.first().get();
List<TypedValue> typedValues = row.getTypedValues();

for (TypedValue tv : typedValues) {
    PropertyType type = tv.getType();
    Object javaValue = tv.toJava();
    System.out.println("Type: " + type + ", Value: " + javaValue);
}

Type Conversion Examples

Working with Dates

Java
import java.time.*;

// Insert with date
client.gql("INSERT (e:Event {" +
    "_id: 'e1', " +
    "name: 'Conference', " +
    "date: DATE('2024-06-15'), " +
    "startTime: DATETIME('2024-06-15T09:00:00Z')" +
    "})");

// Query and convert
Response response = client.gql("MATCH (e:Event) RETURN e.date, e.startTime");
response.first().ifPresent(row -> {
    Object date = row.get(0);      // LocalDate or similar
    Object startTime = row.get(1); // Instant or similar
    System.out.println("Event date: " + date);
    System.out.println("Start time: " + startTime);
});

Working with Points

Java
// Insert with location
client.gql("INSERT (p:Place {" +
    "_id: 'p1', " +
    "name: 'Office', " +
    "location: POINT(37.7749, -122.4194)" +
    "})");

// Query and access point
Response response = client.gql("MATCH (p:Place) RETURN p.location");
response.first().ifPresent(row -> {
    Object location = row.get(0);
    if (location instanceof Point) {
        Point pt = (Point) location;
        System.out.println("Lat: " + pt.getLatitude() + ", Lng: " + pt.getLongitude());
    }
});

Working with Collections

Java
// Insert with list and map
client.gql("INSERT (u:User {" +
    "_id: 'u1', " +
    "name: 'Alice', " +
    "tags: ['developer', 'blogger'], " +
    "metadata: {level: 5, premium: true}" +
    "})");

// Query collections
Response response = client.gql("MATCH (u:User) RETURN u.tags, u.metadata");
response.first().ifPresent(row -> {
    List<?> tags = (List<?>) row.get(0);
    Map<?, ?> metadata = (Map<?, ?>) row.get(1);
    System.out.println("Tags: " + tags);
    System.out.println("Metadata: " + metadata);
});

Complete Example

Java
import com.gqldb.*;
import com.gqldb.types.PropertyType;
import java.util.*;

public class DataTypesExample {
    public static void main(String[] args) {
        GqldbConfig config = GqldbConfig.builder()
            .hosts("192.168.1.100:9000")
            .build();

        try (GqldbClient client = new GqldbClient(config)) {
            client.login("admin", "password");
            client.createGraph("typeDemo");
            client.useGraph("typeDemo");

            // Insert data with various types
            client.gql("INSERT (u:User {" +
                "_id: 'u1', " +
                "name: 'Alice', " +
                "age: 30, " +
                "balance: 1234.56, " +
                "active: true, " +
                "joined: DATE('2023-01-15'), " +
                "location: POINT(40.7128, -74.0060), " +
                "tags: ['developer', 'mentor'], " +
                "settings: {theme: 'dark', notifications: true}" +
                "})");

            // Query and check types
            Response response = client.gql(
                "MATCH (u:User {_id: 'u1'}) " +
                "RETURN u.name, u.age, u.balance, u.active, u.joined, " +
                "u.location, u.tags, u.settings"
            );

            response.first().ifPresent(row -> {
                System.out.println("Name (String): " + row.getString(0));
                System.out.println("Age (long): " + row.getLong(1));
                System.out.println("Balance (double): " + row.getDouble(2));
                System.out.println("Active (boolean): " + row.getBoolean(3));
                System.out.println("Joined: " + row.get(4));
                System.out.println("Location: " + row.get(5));
                System.out.println("Tags: " + row.get(6));
                System.out.println("Settings: " + row.get(7));

                // Check property types
                System.out.println("\nProperty types:");
                List<TypedValue> typedValues = row.getTypedValues();
                List<String> columns = response.getColumns();
                for (int i = 0; i < typedValues.size(); i++) {
                    System.out.println("  " + columns.get(i) + ": " +
                        typedValues.get(i).getType());
                }
            });

            client.dropGraph("typeDemo");

        } catch (GqldbException e) {
            System.err.println("Error: " + e.getMessage());
        }
    }
}