From 08d6928e57b12589cfaaf4fea7b947b8a98e39e3 Mon Sep 17 00:00:00 2001 From: Dmitriy Tverdiakov <11927660+injectives@users.noreply.github.com> Date: Thu, 24 Nov 2022 19:03:05 +0000 Subject: [PATCH] Update SessionConfig.withDatabase documentation (#1334) --- .../java/org/neo4j/driver/SessionConfig.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/driver/src/main/java/org/neo4j/driver/SessionConfig.java b/driver/src/main/java/org/neo4j/driver/SessionConfig.java index f43d747fdc..9511daaf26 100644 --- a/driver/src/main/java/org/neo4j/driver/SessionConfig.java +++ b/driver/src/main/java/org/neo4j/driver/SessionConfig.java @@ -246,16 +246,37 @@ public Builder withDefaultAccessMode(AccessMode mode) { } /** - * Set the database that the newly created session is going to connect to. + * Sets target database name for queries executed within session. *

- * For connecting to servers that support multi-databases, - * it is highly recommended to always set the database explicitly in the {@link SessionConfig} for each session. - * If the database name is not set, then session defaults to connecting to the default database configured in server configuration. + * This option has no explicit value by default, but it is recommended to set one if the target database is + * known in advance. This has the benefit of ensuring a consistent target database name throughout the session + * in a straightforward way and potentially simplifies driver logic as well as reduces network communication + * resulting in better performance. *

- * For servers that do not support multi-databases, leave this database value unset. The only database will be used instead. + * When no explicit name is set, the driver behavior depends on the connection URI scheme supplied to the driver + * on instantiation and Bolt protocol version. + *

+ * Specifically, the following applies: + *

* - * @param database the database the session going to connect to. Provided value should not be {@code null}. - * @return this builder. + * @param database the target database name, must not be {@code null} + * @return this builder */ public Builder withDatabase(String database) { requireNonNull(database, "Database name should not be null.");