# dbvisitor **Repository Path**: zycgit/dbvisitor ## Basic Information - **Project Name**: dbvisitor - **Description**: dbVisitor 提供了一种统一且简便的方式,可访问多种不同类型的数据库。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: dev - **Homepage**: https://www.dbvisitor.net/ - **GVP Project**: No ## Statistics - **Stars**: 365 - **Forks**: 81 - **Created**: 2021-07-21 - **Last Updated**: 2026-02-02 ## Categories & Tags **Categories**: database-dev **Tags**: None ## README # dbVisitor
Vision: “One API Access Any DataBase”
A database access library that provides unified access to different types of databases for Java, aiming to use a single API to access all databases.
Website • Documentation • Blog
--- ## 📖 Introduction **dbVisitor** is a **unified data access foundation** built on the JDBC standard, dedicated to realizing the vision of **“One API Access Any DataBase”**. With its unique **Dual-Layer Adapter Architecture**, it successfully breaks the programming barrier between RDBMS and NoSQL, allowing developers to seamlessly manipulate various databases such as MySQL, MongoDB, and Elasticsearch using **the same set of standard APIs**. dbVisitor does not advocate inventing new syntax to conceal differences, but rather scientifically **manages differences** through **standardization** and **layered abstraction**, providing a general-purpose data foundation for Java applications that is both convenient and retains the flexibility of JDBC.
dbVisitor provides multi-level API abstraction, allowing for free switching between **Simplicity** and **Flexibility**:
- 🛡 **LambdaTemplate**: Shield Differences
- Type-safe Lambda query builder supporting method chaining.
- Single-table CRUD methods, ready to use out of the box, automatically translated into SQL or DSL for the target database.
- 🧱 **Mapper/Interface**: Manage Differences
- Declarative interface programming, supporting `@Query`/XML, separating SQL/DSL logic from code.
- Provides BaseMapper generic methods, eliminating legitimate repetitive development.
- 🔧 **JdbcTemplate**: Pass-Through Differences
- Standard JDBC template methods, supporting pass-through of native SQL and Shell scripts.
- Provides ConnectionCallback, allowing direct access to underlying driver APIs.
## ✨ Features
### ⚙️ Framework Characteristics
- **🛡️ Unified Base**: One API conquers both RDBMS (MySQL, PG...) and NoSQL (Mongo, ES...).
- **🔌 Wide Compatibility**: Pure Java (JDK8+), zero dependencies, perfectly adapted to mainstream frameworks like Spring/Solon.
- **📦 Lightweight**: Minimalist design, core capability depends only on the `cobble` toolkit.
### 🔋 Capabilities
- **API Layered Abstraction**:
- [Programmatic API](https://www.dbvisitor.net/docs/guides/api/program_api): Access database programmatically, characterized by powerful flexibility.
- [Declarative API](https://www.dbvisitor.net/docs/guides/api/declarative_api): Centralize SQL maintenance through interfaces, making the code structure clearer.
- [Generic Mapper](https://www.dbvisitor.net/docs/guides/api/base_mapper): Generic Mapper makes your program more refined at the data access layer.
- [Builder API](https://www.dbvisitor.net/docs/guides/api/lambda_api): Construct query conditions via chain calls, avoiding the tediousness of handwritten SQL.
- [File Mapper](https://www.dbvisitor.net/docs/guides/api/file_mapper): Write SQL or DSL via files, completely separating SQL logic from code.
- [JDBC Adapter](https://www.dbvisitor.net/docs/guides/drivers/about): Provides standard encapsulation of JDBC, supporting access to various non-relational databases.
- **Object Mapping**:
- [One API](https://www.dbvisitor.net/docs/guides/core/mapping/about) handles different types of data sources with a smooth learning curve and no need to master complex concepts.
- Supports intelligent result set mapping, automatically handling [Camel Case Conversion](https://www.dbvisitor.net/docs/guides/core/mapping/camel_case) and property filling.
- Built-in 6 types of [Key Generators](https://www.dbvisitor.net/docs/guides/core/mapping/keytype); custom ones are also supported.
- Tips: Relationship mapping is not supported (e.g., One-to-One, One-to-Many, Many-to-One, Many-to-Many).
- **SQL Rules**:
- [Dynamic SQL Simplification](https://www.dbvisitor.net/docs/guides/rules/about): Introduces `@{...}` rule syntax significantly simplifying dynamic SQL concatenation logic, saying goodbye to cumbersome XML tags.
- [SQL Enhancement Rules](https://www.dbvisitor.net/docs/guides/rules/dynamic_rule): Built-in rules like `@{and}`, `@{or}`, `@{in}`, automatically determining whether conditions take effect based on parameter null values.
- [Argument Processing Rules](https://www.dbvisitor.net/docs/guides/rules/args_rule): Supports directives like `@{md5}`, `@{uuid}`, preprocessing arguments before SQL execution.
- **Argument Processing**:
- Supports [Positional Arguments](https://www.dbvisitor.net/docs/guides/args/position): Use "?" in statements to mark parameters, binding values to the corresponding index (starting from 0).
- Supports [Named Arguments](https://www.dbvisitor.net/docs/guides/args/named): Use syntaxes like :name, &name, or #{...} in statements to name parameters in SQL.
- Supports [SQL Injection](https://www.dbvisitor.net/docs/guides/args/inject): Use ${...} syntax to retrieve values of named parameters and inject the result into the SQL statement.
- Supports [Rule Arguments](https://www.dbvisitor.net/docs/guides/args/rule): Use @{...} syntax to leverage the Rule mechanism to gracefully handle common dynamic SQL scenarios.
- Supports [Interface Mode](https://www.dbvisitor.net/docs/guides/args/interface): Customize parameter setting via interface implementation to meet special scenarios.
- **TypeHandler**:
- Flexible type conversion system automatically handling complex mappings.
- Rich type support covering [Basic Types](https://www.dbvisitor.net/docs/guides/types/handlers/about),
[JSON](https://www.dbvisitor.net/docs/guides/types/json-serialization),
[Enum](https://www.dbvisitor.net/docs/guides/types/enum-handler),
[Array](https://www.dbvisitor.net/docs/guides/types/array-handler),
[DateTime](https://www.dbvisitor.net/docs/guides/types/handlers/datetime-handler),
[GIS](https://www.dbvisitor.net/docs/guides/types/gis-handler),
[Stream](https://www.dbvisitor.net/docs/guides/types/stream-handler),
[Bytes](https://www.dbvisitor.net/docs/guides/types/handlers/bytes-handler), etc.
- **Receive Results**:
- Provides multiple ways to process query results on all types of data sources.
- Common result processing includes [Bean Mapping](https://www.dbvisitor.net/docs/guides/core/mapping/about),
[RowMapper](https://www.dbvisitor.net/docs/guides/result/for_mapper),
[RowCallbackHandler](https://www.dbvisitor.net/docs/guides/result/row_callback),
[ResultSetExtractor](https://www.dbvisitor.net/docs/guides/result/for_extractor).
- **Session/Transaction**:
- Supports multi-datasource transaction management (non-distributed transactions).
- Supports transaction control capabilities identical to Spring, including [7 Transaction Propagation Behaviors](https://www.dbvisitor.net/docs/guides/transaction/propagation).
- Control transactions via [Programmatic](https://www.dbvisitor.net/docs/guides/transaction/manager/program),
[Annotation](https://www.dbvisitor.net/docs/guides/transaction/manager/annotation),
and [Template Method](https://www.dbvisitor.net/docs/guides/transaction/manager/template) approaches.
- Tips: Although dbVisitor unifies transaction call forms, it cannot change the physical characteristics of the underlying database.
- **Advanced Features**:
- Strong affinity for Map structures, supporting multiple result set formats:
- Single value/Single column/Single row/Multi-row/Pagination receive modes.
- Supports returning List\