Releases: neo4j/neo4j-java-driver
6.0.1
The neo4j-java-driver-bom
has been updated to not import netty-bom
.
If you are using Netty Native Transport, please ensure to either:
- Use a compatible Netty Native Transport version with Netty version used by the driver.
- Import
netty-bom
with the desired Netty version (at present, the driver is shipped with Netty 4.2+)
👏 Improvements
- feat(bom): delete netty-bom from neo4j-java-driver-bom #1707
6.0.0
This release brings news features, general improvements and dependency updates.
The sections below describe the main updates in this release and the full changelog is listed in the end.
Neo4j Vector
Neo4j Vector is a new data type introduced in Neo4j server (2025.10, Enterprise Edition).
The driver's type system has been extended to support it.
A new Vector
interface represents Neo4j Vector. At present, it has 6 subtypes:
Int8Vector
-INTEGER8
vector that has Javabyte
elements and can be converted tobyte[]
arrayInt16Vector
-INTEGER16
vector that has Javashort
elements and can be converted toshort[]
arrayInt32Vector
-INTEGER32
vector that has Javaint
elements and can be converted toint[]
arrayInt64Vector
-INTEGER
vector that has Javalong
elements and can be converted tolong[]
arrayFloat32Vector
-FLOAT16
vector that has Javafloat
elements and can be converted tofloat[]
arrayFloat64Vector
-FLOAT
vector that has Javadouble
elements and can be converted todouble[]
array
Similarly to the IsoDuration
, new Value
instance containing Vector
can be created using one of the provided Values#vector(...)
factory methods. The Type
of such Value
is equal to TypeSystem#VECTOR()
.
Usage example:
var value = Values.vector(new float[] {0.0f});
var result = driver.executableQuery("CREATE (:VectorTest {vector: $vector})")
.withParameters(Map.of("vector", value))
.execute();
Since Vector
is a sealed
interface, it works well with Pattern Matching for switch:
switch (value.asVector()) {
case Int8Vector int8Vector -> {
var arr = int8Vector.toArray();
}
case Int16Vector int16Vector -> {
var arr = int16Vector.toArray();
}
case Int32Vector int32Vector -> {
var arr = int32Vector.toArray();
}
case Int64Vector int64Vector -> {
var arr = int64Vector.toArray();
}
case Float32Vector float32Vector -> {
var arr = float32Vector.toArray();
}
case Float64Vector float64Vector -> {
var arr = float64Vector.toArray();
}
}
Alongside Value#asVector()
, it is also possible to map Value
to Vector
using the Value#as(Class<T>)
method. This is especially useful when Vector
subtype is well-known:
var vector = value.as(Float32Vector.class);
It is also possible to map to array directly:
var arr = value.as(float[].class);
When using Object Mapping, it is possible to define record
components both as Vector
and arrays with Vector
annotation:
record DomainRecord(
Float32Vector float32Vector,
@Vector float floatArr) {}
var domainRecord = value.as(DomainRecord.class);
Unsupported Type
The Neo4j Vector is a good example of a new type being introduced to the system. It is possible that at some point the driver version connecting to the server might not support a new future type because it requires a newer protocol version to support it.
A new UnsupportedType
object has been introduced to identify such types and provide some information about them, like:
- name
- minimum protocol version
- an optional message
The Type
of a Value
with UnsupportedType
is equal to TypeSystem#UNSUPPORTED()
.
Usage example:
var unsupportedType = value.asUnsupportedType();
System.out.println(unsupportedType.name());
System.out.println(unsupportedType.minProtocolVersion());
unsupportedType.message().ifPresent(System.out::println);
Sending the UnsupportedType
back to the server is not supported.
Bill of Materials (BOM)
A new Maven artifact neo4j-java-driver-bom
represents driver's Bill of Materials (BOM).
It is especially useful when additional driver dependencies are used.
Usage example (Maven):
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>6.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
The driver BOM also imports netty-bom
to ensure compatible versions, especially when Netty Native Transport is used.
Should it be necessary, users can override netty-bom
version by importing it before the driver BOM:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${netty-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>6.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Query API
NOTE: This feature is in preview.
Neo4j Query API is an HTTP API for executing Cypher statements.
The driver supports connecting to this API over HTTP.
The Query API support is enabled by:
- including an extra dependency
- using
https
orhttp
URI scheme
Example (Maven):
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j.bolt</groupId>
<artifactId>neo4j-bolt-connection-query-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!--> BOM ensures the versions are compatible <-->
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-bom</artifactId>
<type>pom</type>
<scope>import</scope>
<version>6.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Driver creation example:
var driver = GraphDatabase.driver("https://query.api.local", authToken);
The are some limitations with this integration at the moment. The main unsuported items are listed below:
- Home database resolution.
- Records streaming.
- All records are loaded ahead of time to client-side memory. If you deal with large datasets, this integration might need more memory.
- Neo4j Vector.
- Unsupported Type.
- Transaction metadata.
- Notification preferences.
ResultSummary#resultAvailableAfter(TimeUnit)
.ResultSummary#resultConsumedAfter(TimeUnit)
.ResultSummary#queryType()
.ResultSummary#plan()
.ResultSummary#profile()
.
Since home database resolution is not supported, the database name MUST be set explicitly using the driver API. Alternatively, it is possible to append the default database name to the URI, it will be used when no database name is set explicitly.
Example: https://query.api.local?defaultDatabase=neo4j
Reducing the number of dependencies
When the driver is used with Query API only, it is possible to exclude some dependencies to reduce the overall amount:
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<exclusions>
<exclusion>
<groupId>org.neo4j.bolt</groupId>
<artifactId>neo4j-bolt-connection-netty</artifactId>
</exclusion>
</exclusions>
</dependency>
Specifically, this removes the following dependencies:
- org.neo4j.bolt:neo4j-bolt-connection-netty
- io.netty:netty-handler
- io.netty:netty-common
- io.netty:netty-resolver
- io.netty:netty-buffer
- io.netty:netty-transport
- io.netty:netty-transport-native-unix-common
- io.netty:netty-codec-base
- io.netty:netty-tcnative-classes
- io.netty:netty-handler
Unix Domain Socket
bolt+unix
URI scheme allows connecting to Neo4j server over Unix Domain Socket.
Example:
try (var driver = GraphDatabase.driver("bolt+unix:///var/run/neo4j.sock")) {
var result = driver.executableQuery("SHOW DATABASES")
.withConfig(QueryConfig.builder().withDatabase("system").build())
.execute();
result.records().forEach(System.out::println);
}
While the driver does not impose any special limitations on such connections, the server has a dedicated purpose for them - administration. Therefore, it limits interations to system
database only. See the server configuration settings.
Netty Native Transport
Using Netty Native Transport may bring better performance and less garbage collection as mentioned in the Netty documentation.
In addition, ...
5.28.10
6.0.0-RC1
This is the first release candidate that provides a preview of the new features and general improvements.
⭐ New Features
- feat(tfo): add experimental support for TFO #1696
- feat(unix): add support for bolt+unix #1700
- feat(unsupportedType): add support for Bolt Unsupported Type #1691
👏 Improvements
- feat(vector): add Value#asVector() #1701
- feat(tfo): update config naming #1699
- test: fix ReactiveResultRecordPublisherVerificationIT #1695
- feat(vector): update naming #1692
- fix(acquisition): avoid infinite connection timeout if there is a limit #1689
- feat(native): add support for Netty native transports #1690
- docs(retries): add a note about implicit transaction #1687
- feat(acquisition): apply acquisition timeout to all steps #1685
- feat(observability): allow setting null provider #1686
🔧 Build
- build(deps): update dependencies #1694
4.4.21
6.0.0-beta01
This is the first beta release that provides a preview of the new features and general improvements.
⭐ New Features
- feat(observability): add Observation SPI #1682
👏 Improvements
- feat(observability): add Javadoc #1684
- fix(object-mapping): try making record components accessible #1681
- docs(retry): mention ExecutableQuery in withMaxTransactionRetyTime #1679
🔧 Build
- build(deps): update dependencies #1683
6.0.0-alpha03
5.28.9
6.0.0-alpha02
This is the second alpha release that provides a preview of the new features and general improvements.
⭐ New Features
- feat(vector): Introduce support for Neo4j Vector #1663
👏 Improvements
- feat(gql-status-object): Introduce GqlNotification #1667
- feat(object-mapping): support mapping types with restricted access #1668
- feat(gql-status-object): make GQL Status Object GA #1669
- feat(gql-error): add GQLSTATUS finders #1671
- feat(gql-error): make GQL Error GA #1673
- fix(retry): make RetryLogic executor threads daemon #1661
- perf(value): optimise value handling for Bolt Connection #1657
🔧 Build
5.28.8
This in an LTS release.
It brings general improvements and dependency updates.
👏 Improvements
- feat(gql-status-object): Introduce GqlNotification #1641
- feat(object-mapping): support mapping types with restricted access #1670
- feat(gql-error): add GQLSTATUS finders #1672
🔧 Dependency Management
- build(deps): update dependencies #1675