Neo4j 5 中对 Java API 的更改

此页面列出了 Neo4j 4.4 和 Neo4j 5.x 之间 Java API 的所有更改。

对类、接口和枚举的更改

移除和添加的列表
变更 操作

FormattedLogFormat

已移除

格式在 Log4j 2 配置文件中配置。

Logger

已移除

直接使用 Log

OnlineBackup

已移除

使用独立工具。

TransactionStreamingStrategy

已移除

由在线备份使用。

ClusterDatabaseManagementService

已移除

使用 EnterpriseDatabaseManagementService

ClusterDatabaseManagementServiceBuilder

已移除

使用 EnterpriseDatabaseManagementServiceBuilder

InProcessNeo4j

已移除

意外添加到公共 API 中。

CypherParserVersion

已移除

在已移除设置中使用的枚举。

DriverApi

已移除

在已移除设置中使用的枚举。

Mode

已移除

在已移除设置中使用的枚举。

SchemaIndex

已移除

在已移除设置中使用的枚举。

NamedService

用于为 @ServiceProvider 提供 .getName()

SeedProvider

种子提供者的入口点。参见 SeedProvider

Neo4jDatabaseManagementServiceBuilder

*DatabaseManagementServiceBuilder 的通用接口。

InstanceModeConstraint

在设置中使用的新的枚举。

SystemDatabaseMode

在设置中使用的新的枚举。

对方法的更改

org.neo4j.logging.Log

以下方法已移除

方法 变更 操作

Logger errorLogger()

已移除

直接使用 Log.error(…​)

Logger warnLogger()

已移除

直接使用 Log.warn(…​)

Logger infoLogger()

已移除

直接使用 Log.info(…​)

Logger debugLogger()

已移除

直接使用 Log.debug(…​)

org.neo4j.graphdb.config.Setting<T>

以下方法已移除

方法 变更 操作

boolean internal()

已移除

不再使用。用于将设置标记为内部隐藏设置。

org.neo4j.graphdb.Entity

以下方法已添加。它们从继承的 NodeRelationship 中可见

方法 变更 操作

String getElementId()

返回唯一的元素 ID。保证在事务内唯一。

void delete()

NodeRelationship 移动到通用接口。

org.neo4j.graphdb.schema.IndexType

以下索引类型已移除

索引类型 变更 操作

IndexType.BTREE

已移除

IndexType.RANGE 替换。

org.neo4j.graphdb.spatial.Coordinate

以下方法已移除

方法 变更 操作

List<Double> getCoordinate()

已移除

被以下两个方法替换
double[] getCoordinate() — 获取坐标。仅用于读取值。
double[] getCoordinateCopy() — 获取坐标的副本。可以安全地修改和存储。

org.neo4j.graphdb.Transaction

以下方法已添加

方法 变更 操作

Node getNodeByElementId(String)

根据元素 ID 查找节点。

Relationship getRelationshipByElementId(String)

根据元素 ID 查找关系。

org.neo4j.harness.junit.extension.Neo4jExtensionBuilder

以下方法已移除

方法 变更 操作

Neo4jExtensionBuilder copyFrom(File)

已移除

使用 Neo4jExtensionBuilder.copyFrom(Path)

Neo4jExtensionBuilder withFolder(File)

已移除

使用 Neo4jExtensionBuilder.withFolder(Path)

Neo4jExtensionBuilder withExtensionFactories(Iterable<ExtensionFactory<?>>)

已移除

已移除。

Neo4jExtensionBuilder withFixture(File)

已移除

使用 Neo4jExtensionBuilder.withFixture(Path)

org.neo4j.harness.junit.rule.Neo4jRule

以下方法已移除

方法 变更 操作

Neo4jRule(File)

已移除

使用 Neo4jRule(Path)

Neo4jRule copyFrom(File)

已移除

使用 Neo4jRule.copyFrom(Path)

Neo4jRule withExtensionFactories(Iterable<ExtensionFactory<?>>)

已移除

已移除。

Neo4jRule withFixture(File)

已移除

使用 Neo4jRule.withFixture(Path)

org.neo4j.harness.Neo4jBuilders

以下方法已移除

方法 变更 操作

Neo4jBuilder newInProcessBuilder(File)

已移除

使用 Neo4jBuilders.newInProcessBuilder(Path)

org.neo4j.harness.Neo4jConfigurator<T>

以下方法已移除

方法 变更 操作

T copyFrom(File)

已移除

使用 Neo4jConfigurator.copyFrom(Path)

T withExtensionFactories(Iterable<ExtensionFactory<?>>)

已移除

已移除。

T withFixture(File)

已移除

使用 Neo4jConfigurator.withFixture(Path)

T withWorkingDir(File)

已移除

使用 Neo4jConfigurator.withWorkingDir(Path)

com.neo4j.harness.junit.rule.EnterpriseNeo4jRule

接受 File 的已弃用构造函数已移除

方法 变更 操作

EnterpriseNeo4jRule(File)

已移除

使用 EnterpriseNeo4jRule(Path)

org.neo4j.kernel.api.exceptions.Status

以下状态码已添加

状态码 变更 描述

Database.HomeDatabaseNotFound

提供的 home 数据库当前不存在。

Request.DeprecatedFormat

请求的格式已弃用。

Schema.HintedIndexNotFound

提示索引不存在,请检查架构。

Statement.ParameterNotProvided

未向查询提供足够的参数。

Statement.UnsupportedOperationError

以下状态码已移除

Statement.MissingAlias 已移除

Transaction.TransientTransactionFailure

已移除

一些状态码已重命名以指示从 WARNINGINFORMATION 的严重性变化

旧名称 新名称

Statement.CartesianProductWarning

Statement.CartesianProduct

Statement.DynamicPropertyWarning

Statement.DynamicProperty

Statement.EagerOperatorWarning

Statement.EagerOperator

Statement.ExhaustiveShortestPathWarning

Statement.ExhaustiveShortestPath

Statement.ExperimentalFeature

Statement.RuntimeExperimental

Statement.NoApplicableIndexWarning

Statement.NoApplicableIndex

Statement.SubqueryVariableShadowingWarning

Statement.SubqueryVariableShadowing

Statement.UnboundedVariableLengthPatternWarning

Statement.UnboundedVariableLengthPattern

重命名的类、接口和枚举

旧名称 新名称

com.neo4j.configuration.ServerGroupName

class com.neo4j.configuration.ServerTag

com.neo4j.configuration.CausalClusteringSettings

com.neo4j.configuration.ClusterSettings

com.neo4j.configuration.FabricEnterpriseSettings

com.neo4j.fabric.configuration.FabricEnterpriseSettings

org.neo4j.graphdb.event.DatabaseEventListener

以下两种方法不再有默认实现,需要由监听器实现

  • void databaseCreate(DatabaseEventContext)

  • void databaseDrop(DatabaseEventContext)

org.neo4j.graphdb.GraphDatabaseService

添加了一个新方法,它是现有同名方法的非阻塞变体

  • boolean isAvailable()

org.neo4j.graphdb.Node

以下方法已更改为返回ResourceIterable而不是Iterable

方法 变更

ResourceIterable<Relationship> getRelationships()

ResourceIterable<Relationship> getRelationships(Direction)

ResourceIterable<Relationship> getRelationships(RelationshipType…​)

ResourceIterable<Relationship> getRelationships(Direction, RelationshipType…​)

Iterable<Relationship> getRelationships()

已移除

Iterable<Relationship> getRelationships(Direction)

已移除

Iterable<Relationship> getRelationships(RelationshipType…​)

已移除

Iterable<Relationship> getRelationships(Direction, RelationshipType…​)

已移除

org.neo4j.dbms.api.DatabaseManagementServiceBuilder

此类现在实现了Neo4jDatabaseManagementServiceBuilder,这是现在首选的接口。作为此更改的一部分,以下字段和方法已删除,因为它们暴露了内部实现

  • Config.Builder config

  • List<DatabaseEventListener> databaseEventListeners

  • DependencyResolver dependencies

  • List<ExtensionFactory<?>> extensions

  • Path homeDirectory

  • Monitors monitors

  • Map<String,URLAccessRule> urlAccessRules

  • LogProvider userLogProvider

  • DatabaseManagementServiceBuilder(File)

  • DatabaseManagementServiceBuilder(Path, Predicate<Class<? extends ExtensionFactory>>)

  • DatabaseManagementServiceBuilder loadPropertiesFromFile(String)

  • DatabaseManagementServiceBuilder setConfigRaw(Map<String,String>)

  • DatabaseManagementServiceBuilder setExternalDependencies(DependencyResolver)

  • DatabaseManagementServiceBuilder setMonitors(Monitors)

  • DatabaseManagementServiceBuilder addURLAccessRule(String, URLAccessRule)

  • DatabaseManagementService newDatabaseManagementService(Config, ExternalDependencies)

  • DbmsInfo getDbmsInfo(Config)

  • String getEdition()

  • Function<GlobalModule,AbstractEditionModule> getEditionFactory(Config)

  • Config augmentConfig(Config)

  • ExternalDependencies databaseDependencies()

Neo4j 设置变更

com.neo4j.configuration.OnlineBackupSettings

设置 变更

Setting<TransactionStreamingStrategy> incremental_backup_strategy

已移除

Setting<Duration> store_copy_max_retry_time_per_request

com.neo4j.configuration.MetricsSettings

所有启用和禁用度量类型的设置都替换为metrics_filter,它采用一个正则表达式来指定要启用的度量

设置 变更

Setting<List<GlobbingPattern>> metrics_filter

Setting<Boolean> bolt_messages_enabled

已移除

Setting<Boolean> causal_clustering_enabled

已移除

Setting<Boolean> cypher_planning_enabled

已移除

Setting<Boolean> database_counts_enabled

已移除

Setting<Boolean> database_operation_count_enabled

已移除

Setting<Boolean> jvm_buffers_enabled

已移除

Setting<Boolean> jvm_file_descriptors_enabled

已移除

Setting<Boolean> jvm_gc_enabled

已移除

Setting<Boolean> jvm_heap_enabled

已移除

Setting<Boolean> jvm_memory_enabled

已移除

Setting<Boolean> jvm_pause_time_enabled

已移除

Setting<Boolean> jvm_threads_enabled

已移除

Setting<Boolean> metrics_namespaces_enabled

已移除

Setting<Boolean> neo_check_pointing_enabled

已移除

Setting<Boolean> neo_counts_enabled

已移除

Setting<Boolean> neo_memory_pools_enabled

已移除

Setting<Boolean> neo_page_cache_enabled

已移除

Setting<Boolean> neo_server_enabled

已移除

Setting<Boolean> neo_store_size_enabled

已移除

Setting<Boolean> neo_transaction_logs_enabled

已移除

Setting<Boolean> neo_tx_enabled

已移除

com.neo4j.configuration.OnlineBackupSettings

设置 变更

Setting<Duration> store_copy_max_retry_time_per_request

Setting<TransactionStreamingStrategy> incremental_backup_strategy

已移除

com.neo4j.configuration.SecuritySettings

设置 变更

Setting<String> key_name

Setting<SecureString> keystore_password

Setting<Path> keystore_path

Setting<String> ldap_authorization_nested_groups_search_filter

Setting<Boolean> ldap_authorization_nested_groups_enabled

Setting<Boolean> ldap_authentication_use_samaccountname

已移除

作为日志变更的一部分,以下设置已删除并移至 Log4j 2 配置文件

设置 变更

Setting<Path> security_log_filename

已移除

Setting<FormattedLogFormat> security_log_format

已移除

Setting<Level> security_log_level

已移除

Setting<Integer> store_security_log_max_archives

已移除

Setting<Duration> store_security_log_rotation_delay

已移除

Setting<Long> store_security_log_rotation_threshold

已移除

com.neo4j.configuration.SecuritySettings.OIDCSetting

设置 变更

String name()

Setting<URI> redirect_uri

已移除

com.neo4j.configuration.EnterpriseEditionSettings

设置 变更

int MAX_PRIMARIES = 11

int MAX_SECONDARIES = 20

int MIN_PRIMARIES = 1

int MIN_SECONDARIES = 0

Setting<Set<String>> initial_allowed_databases

Setting<String> initial_database_allocator

Setting<Integer> initial_default_primaries_count

Setting<Integer> initial_default_secondaries_count

Setting<Set<String>> initial_denied_databases

Setting<InstanceModeConstraint> initial_mode_constraint

Setting<List<ServerTag>> server_groups

Setting<SystemDatabaseMode> system_database_mode

Setting<Boolean> enable_clustering_in_standalone

已移除

Setting<List<String>> dynamic_setting_whitelist

已移除

com.neo4j.fabric.configuration.FabricEnterpriseSettings

设置 变更

Setting<DriverApi> driver_api

已移除

com.neo4j.configuration.FabricEnterpriseSettings.GraphSetting

设置 变更

Setting<String> driver_policy

Setting<DriverApi> driver_api

已移除

Neo4j 集群设置变更

com.neo4j.configuration.ClusterNetworkSettings

设置 变更

Setting<Duration> catchup_client_inactivity_timeout

Setting<Duration> network_handshake_timeout

Setting<Integer> network_max_chunk_size

Setting<List<String>> network_supported_compression_algos

Setting<Boolean> network_use_native_transport

com.neo4j.configuration.KubernetesSettings

设置 变更

Setting<SocketAddress> kubernetes_address

Setting<Path> kubernetes_ca_crt

Setting<String> kubernetes_cluster_domain

Setting<String> kubernetes_label_selector

Setting<Path> kubernetes_namespace

Setting<String> kubernetes_service_port_name

Setting<Path> kubernetes_token

com.neo4j.configuration.ClusterSettings

添加了一些常量

设置 变更

int DEFAULT_DISCOVERY_PORT = 5000

int DEFAULT_RAFT_PORT = 7000

int DEFAULT_TRANSACTION_PORT = 6000

以下设置已移至ClusterNetworkSettings类并重命名

设置 变更

Setting<Duration> catch_up_client_inactivity_timeout

已移除

Setting<Duration> handshake_timeout

已移除

Setting<Integer> store_copy_chunk_size

已移除

Setting<List<String>> compression_implementations

已移除

以下设置已移至KubernetesSettings

设置 变更

Setting<SocketAddress> kubernetes_address .>

已移除

Setting<Path> kubernetes_ca_crt

已移除

Setting<String> kubernetes_cluster_domain

已移除

Setting<String> kubernetes_label_selector

已移除

Setting<Path> kubernetes_namespace

已移除

Setting<String> kubernetes_service_port_name

已移除

Setting<Path> kubernetes_token

已移除

添加了以下设置

设置 变更

Setting<Duration> catchup_pull_interval

Setting<List<String>> catchup_upstream_strategy

Setting<String> catchup_user_defined_upstream_strategy

Setting<SocketAddress> cluster_advertised_address

Setting<SocketAddress> cluster_listen_address

Setting<List<SocketAddress>> discovery_initial_members

Setting<Level> discovery_log_level

Setting<Long> raft_apply_buffer_max_bytes

Setting<Integer> raft_apply_buffer_max_entries

Setting<Duration> raft_binding_timeout

Setting<Integer> raft_client_max_channels

Setting<DurationRange> raft_election_failure_detection_window

Setting<Long> raft_in_queue_batch_max_bytes

Setting<DurationRange> raft_leader_failure_detection_window

Setting<SelectionStrategies> raft_leader_transfer_balancing_strategy

Setting<ServerTag> raft_leader_transfer_priority_group

Setting<Integer> minimum_initial_members

Setting<String> raft_log_prune_strategy

Setting<Long> raft_log_shipping_buffer_max_bytes

Setting<Integer> raft_log_shipping_buffer_max_entries

Setting<Duration> raft_membership_join_max_lag

Setting<Duration> raft_membership_join_timeout

Setting<String> routing_load_balancing_plugin

Setting<Boolean> routing_load_balancing_shuffle_enabled

Setting<Boolean> routing_reads_on_primaries_enabled

Setting<Boolean> routing_reads_on_writers_enabled

Setting<Boolean> security_cluster_status_auth_enabled

Setting<List<String>> seed_from_uri_providers

Setting<List<ServerTag>> catchup_connect_randomly_to_server_group

以下设置已删除

设置 变更

Setting<Integer> catchup_batch_size

已移除

Setting<List<ApplicationProtocolVersion>> catchup_implementations

已移除

Setting<Boolean> cluster_allow_reads_on_followers

已移除

Setting<Boolean> cluster_allow_reads_on_leader

已移除

Setting<Duration> cluster_binding_timeout

已移除

Setting<Duration> cluster_topology_refresh

已移除

Setting<Integer> command_applier_parallelism

已移除

Setting<List<ServerGroupName>> connect_randomly_to_server_group_strategy

已移除

Setting<ServerGroupName> default_leadership_priority_group

已移除

Setting<DurationRange> election_failure_detection_window

已移除

Setting<Boolean> enable_pre_voting

已移除

Setting<Integer> global_session_tracker_state_size

已移除

Setting<Long> in_flight_cache_max_bytes

已移除

Setting<Integer> in_flight_cache_max_entries

已移除

Setting<InFlightCacheType in_flight_cache_type

已移除

Setting<List<SocketAddress>> initial_discovery_members

已移除

Setting<Duration> join_catch_up_max_lag

已移除

Setting<Duration> join_catch_up_timeout

已移除

Setting<Integer> last_flushed_state_size

已移除

Setting<SelectionStrategies> leader_balancing

已移除

Setting<Duration> leader_election_timeout

已移除

Setting<DurationRange> leader_failure_detection_window

已移除

Setting<String> load_balancing_plugin

已移除

Setting<Boolean> load_balancing_shuffle

已移除

Setting<Integer> log_shipping_max_lag

已移除

Setting<Duration> log_shipping_retry_timeout

已移除

Setting<Integer> max_raft_channels

已移除

Setting<Level> middleware_logging_level

已移除

Setting<Integer> minimum_core_cluster_size_at_formation

已移除

Setting<Integer> minimum_core_cluster_size_at_runtime

已移除

Setting<Boolean> multi_dc_license

已移除

Setting<Duration> pull_interval

已移除

Setting<Integer> raft_handler_parallelism

已移除

Setting<List<ApplicationProtocolVersion>> raft_implementations

已移除

Setting<Long> raft_in_queue_max_batch_bytes

已移除

Setting<Integer> raft_log_entry_prefetch_buffer_max_entries

已移除

Setting<String> raft_log_implementation

已移除

Setting<String> raft_log_pruning_strategy

已移除

Setting<Integer> raft_membership_state_size

已移除

Setting<Boolean> refuse_to_be_leader

已移除

Setting<Integer> replicated_lease_state_size

已移除

Setting<Duration> replication_leader_await_timeout

已移除

Setting<Duration> replication_retry_timeout_base

已移除

Setting<Duration> replication_retry_timeout_limit

已移除

设置<List<ServerGroupName>> server_groups

已移除

设置<Integer> state_machine_apply_max_batch_size

已移除

设置<Integer> state_machine_flush_window_size

已移除

设置<Boolean> status_auth_enabled

已移除

设置<Duration> status_throughput_window

已移除

设置<Integer> store_copy_parallelism

已移除

设置<Integer> term_state_size

已移除

设置<SocketAddress> transaction_advertised_address

已移除

设置<SocketAddress> transaction_listen_address

已移除

设置<Duration> unknown_address_logging_throttle

已移除

设置<List<String>> upstream_selection_strategy

已移除

设置<String> user_defined_upstream_selection_strategy

已移除

设置<Integer> vote_state_size

已移除

org.neo4j.configuration.connectors.BoltConnector

设置 变更

设置<Duration> thread_pool_shutdown_wait_time

已移除

org.neo4j.configuration.GraphDatabaseSettings

添加了以下设置

设置 变更

设置<String> initial_default_database

设置<Boolean> cypher_render_plan_descriptions

以下设置已删除

设置 变更

设置<String> default_allowed

已移除

设置<String> default_database

已移除

设置<String> default_schema_provider

已移除

Setting<Boolean> enable_clustering_in_standalone

已移除

设置<Boolean> allow_upgrade

已移除

设置<CypherParserVersion> cypher_parser_version

已移除

设置<Integer> lucene_searcher_cache_size

已移除

设置<Mode> mode

已移除

设置<String> pagecache_swapper

已移除

设置<String> pagecache_warmup_prefetch_whitelist

已移除

设置<DriverApi> routing_driver_api

已移除

设置<String> procedure_roles

已移除

设置<String> procedure_whitelist

已移除

设置<Boolean> read_only

已移除

设置<Duration> reconciler_maximum_backoff

已移除

设置<Integer> reconciler_maximum_parallelism

已移除

设置<Boolean> reconciler_may_retry

已移除

设置<Duration> reconciler_minimum_backoff

已移除

设置<Integer> upgrade_processors

已移除

record_format 设置已重命名为 db_format,以便将来可以选择非记录格式。

设置 变更

设置<String> db_format

设置<String> record_format

已移除

以下设置已移除,其默认值现已固定。

设置 变更

设置<Boolean> log_queries_allocation_logging_enabled

已移除

设置<Boolean> log_queries_detailed_time_logging_enabled

已移除

设置<Integer> log_queries_max_archives

已移除

设置<Boolean> log_queries_page_detail_logging_enabled

已移除

设置<Boolean> log_queries_parameter_full_entities

已移除

设置<Boolean> log_queries_runtime_logging_enabled

已移除

设置<Boolean> log_queries_transaction_id

已移除

设置<Boolean> track_query_allocation

已移除

pagecache_memory 设置的类型已更改。

设置 变更

设置<Long> pagecache_memory

设置<String> pagecache_memory

已移除

作为日志记录更改的一部分,添加了两个新设置,它们将指向 Log4j 2 配置文件。所有旧的日志记录设置都已移除。

设置 变更

设置<Path> server_logging_config_path

设置<Path> user_logging_config_path

设置<Boolean> debug_log_enabled

设置<FormattedLogFormat> default_log_format

已移除

设置<FormattedLogFormat> store_internal_log_format

已移除

设置<FormattedLogFormat> log_query_format

已移除

设置<FormattedLogFormat> store_user_log_format

已移除

设置<Path> store_internal_log_path

已移除

设置<Level> store_internal_log_level

已移除

设置<Integer> store_internal_log_max_archives

已移除

设置<Duration> store_internal_log_rotation_delay

已移除

设置<Long> store_internal_log_rotation_threshold

已移除

设置<Path> store_user_log_path

已移除

设置<Integer> store_user_log_max_archives

已移除

设置<Duration> store_user_log_rotation_delay

已移除

设置<Long> store_user_log_rotation_threshold

已移除

设置<Boolean> store_user_log_to_stdout

已移除

设置<Path> log_queries_filename

已移除

设置<Long> log_queries_rotation_threshold

已移除

遍历 API 的变更

可以通过 Transaction.traversalDescription()Transaction.bidirectionalTraversalDescription() 访问遍历 API。有关完整文档,请参阅 Java 参考 → 遍历框架

作为遍历 API 一部分添加的类、接口和枚举

接口 org.neo4j.graphdb.traversal.BidirectionalTraversalDescription

接口

org.neo4j.graphdb.traversal.BranchCollisionDetector

枚举

org.neo4j.graphdb.traversal.BranchOrderingPolicies

接口

org.neo4j.graphdb.traversal.BranchOrderingPolicy

接口

org.neo4j.graphdb.traversal.BranchState<STATE>

枚举

org.neo4j.graphdb.traversal.Evaluation

接口

org.neo4j.graphdb.traversal.Evaluator

org.neo4j.graphdb.traversal.Evaluators

接口

org.neo4j.graphdb.traversal.InitialBranchState<STATE>

接口

org.neo4j.graphdb.traversal.PathEvaluator<STATE>

org.neo4j.graphdb.traversal.Paths

枚举

org.neo4j.graphdb.traversal.SideSelectorPolicies

接口

org.neo4j.graphdb.traversal.TraversalBranch

接口

org.neo4j.graphdb.traversal.TraversalDescription

接口

org.neo4j.graphdb.traversal.TraversalMetadata

接口

org.neo4j.graphdb.traversal.Traverser

枚举

org.neo4j.graphdb.traversal.Uniqueness

接口

org.neo4j.graphdb.traversal.UniquenessFactory

接口

org.neo4j.graphdb.traversal.UniquenessFilter

org.neo4j.graphdb.PathExpanders

添加了一些常用的 PathExpander

设置 变更

allTypesAndDirections()

forConstantDirectionWithTypes(RelationshipType…​)

forDirection(Direction)

forType(RelationshipType)

forTypeAndDirection(RelationshipType, Direction)

forTypesAndDirections(RelationshipType, Direction, RelationshipType, Direction, Object…​)

printingWrapper(…​)