### GET command example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/get.md Example showing how to set a string key and then read it with GET. The GET returns a ResultSet with one row containing the VALUE as a String in text mode or byte[] in binary mode. ```text SET demo:message hello ``` ```text GET demo:message ``` -------------------------------- ### SETRANGE Example Commands Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/setrange.md Example usage: first sets a key to 'hello', then overwrites starting at offset 1 with 'a', resulting in 'hallo'. The return value is the length of the string after modification. ```text SET demo:message hello ``` ```text SETRANGE demo:message 1 a ``` -------------------------------- ### BRPOPLPUSH Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/brpoplpush.md Example showing how to push elements to a queue and then use BRPOPLPUSH to move the tail element from the source to the destination head. The example inserts elements before waiting. ```text RPUSH demo:queue first second BRPOPLPUSH demo:queue demo:processing 1 ``` -------------------------------- ### SQL query with positional placeholders Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md Example SQL statement using `?` placeholders that are bound in order by dbVisitor. Container indexes start at 0, while JDBC PreparedStatement indexes start at 1. ```sql select * from users where id > ? and status = ? ``` -------------------------------- ### OBJECT ENCODING Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/object-encoding.md Example showing how to set a key and then retrieve its encoding using OBJECT ENCODING. ```text SET demo:message hello ``` ```text OBJECT ENCODING demo:message ``` -------------------------------- ### TOUCH Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/touch.md Example showing how to use TOUCH on a key after setting it with SET. The command returns the number of keys that were touched. ```text SET demo:message hello TOUCH demo:message ``` -------------------------------- ### MSET Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/mset.md Example usage writing two key-value pairs (demo:name and demo:city) in a single command. ```text MSET demo:name mali demo:city Shanghai ``` -------------------------------- ### Placeholder commands for Elasticsearch operations Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-elastic/src/test/resources/elastic_tests/placeholder_commands.txt A list of example commands using '?' placeholders for various Elasticsearch operations such as GET, POST, and PUT. These are used in tests to verify placeholder substitution. ```text GET /users/_source/{?}; GET /users/_search?q={?}; POST /users/doc { "name": ?, "age": ? }; POST /users/search { "query": { "term": { "name": ? } } }; PUT /users/doc/{?} { "name": "Fixed", "age": ? }; PUT /users/doc/{?} ?; ``` -------------------------------- ### COPY Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/copy.md Example showing how to use COPY: first sets a key 'demo:original' to 'hello', then copies it to 'demo:copy' with REPLACE to overwrite if it exists. ```text SET demo:original hello COPY demo:original demo:copy REPLACE ``` -------------------------------- ### GETSET Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/getset.md Example showing SET followed by GETSET. SET stores 'hello' at demo:message, then GETSET replaces it with 'world' and returns the previous value. ```text SET demo:message hello GETSET demo:message world ``` -------------------------------- ### LMPOP Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lmpop.md Example showing how to use LMPOP after pushing elements to a list. Pops up to 2 elements from the left of demo:queue. ```text RPUSH demo:queue first second LMPOP 1 demo:queue LEFT COUNT 2 ``` -------------------------------- ### GETDEL Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/getdel.md Example usage: SET a key then GETDEL it. The command reads the string and deletes its key. ```text SET demo:message hello GETDEL demo:message ``` -------------------------------- ### Use named positional arguments (Example 4) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md Each `?` placeholder implicitly gets a name following the `arg` rule (e.g., arg0, arg1). Use these names with `:arg0` and `:arg1` in the SQL. ```java Object[] args = new Object[] { 2, "Dave"}; jdbcTemplate.queryForList("select * from users where id > :arg0 and name = :arg1", args); ``` -------------------------------- ### DUMP Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/dump.md Example showing how to use DUMP after setting a key. The result is a ResultSet with one row containing a VALUE field of BYTES type. ```text SET demo:message hello DUMP demo:message ``` -------------------------------- ### RENAME Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/rename.md Example demonstrating renaming a key. The destination key is overwritten if it exists; a missing source key causes an error. ```text SET demo:original hello RENAME demo:original demo:renamed ``` -------------------------------- ### EXPIRETIME Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/expiretime.md Example showing how to set a key with an expiration and then read its expiration timestamp using EXPIRETIME. ```text SET demo:message hello EX 60 EXPIRETIME demo:message ``` -------------------------------- ### Bind arguments with a List (Example 2) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md Passes arguments as a List to `queryForList`. The `?` placeholders are bound in list order. ```java List args = Arrays.asList(2, "Dave"); jdbcTemplate.queryForList("select * from users where id > ? and name = ?", args); ``` -------------------------------- ### GET /users/_search?q={?} Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-elastic/src/test/resources/elastic_tests/placeholder_commands.txt Searches the users index using a query string parameter, where the query value is a placeholder. ```APIDOC ## GET /users/_search?q={?} ### Description Searches the users index using a query string parameter, where the query value is a placeholder. ### Method GET ### Endpoint /users/_search?q={?} ### Parameters #### Query Parameters - **q** (string) - Required - The query string placeholder. ``` -------------------------------- ### EXPIRE Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/expire.md Example showing how to set a key and then expire it after 60 seconds. The command returns 1 if the timeout was set, 0 otherwise. ```text SET demo:message hello ``` ```text EXPIRE demo:message 60 ``` -------------------------------- ### GET /users/_source/{?} Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-elastic/src/test/resources/elastic_tests/placeholder_commands.txt Retrieves a document from the users index by its ID, where the ID is a placeholder. ```APIDOC ## GET /users/_source/{?} ### Description Retrieves a document from the users index by its ID, where the ID is a placeholder. ### Method GET ### Endpoint /users/_source/{?} ### Parameters #### Path Parameters - **{?}** (string) - Required - The document ID placeholder. ``` -------------------------------- ### Bind arguments with an array (Example 1) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md Passes arguments as an Object array to `queryForList`. The `?` placeholders are bound in array order. ```java Object[] args = new Object[] { 2, "Dave"}; jdbcTemplate.queryForList("select * from users where id > ? and name = ?", args); ``` -------------------------------- ### HEXISTS Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hexists.md Example demonstrating how to set a hash field and then check its existence using HEXISTS. ```text HSET demo:user name mali HEXISTS demo:user name ``` -------------------------------- ### GETEX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/getex.md Example usage: sets a key with SET, then reads it with GETEX while setting expiration to 60 seconds. A missing key returns one row with a null VALUE. ```text SET demo:message hello GETEX demo:message EX 60 ``` -------------------------------- ### UNLINK Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/unlink.md Example showing how to set a key and then unlink it. The result is the number of keys removed. ```text SET demo:message hello UNLINK demo:message ``` -------------------------------- ### ECHO Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/server/echo.md Example usage of the ECHO command with the message 'hello'. ```text ECHO hello ``` -------------------------------- ### SELECT example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/server/select.md Example usage of the SELECT command: switches to database 1 and then back to database 0. Returns 1 on success; throws an exception otherwise. ```text SELECT 1 SELECT 0 ``` -------------------------------- ### SUNIONSTORE Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/sunionstore.md Example usage: adds members to two sets and stores their union in a destination set. ```text SADD demo:tags java jdbc SADD demo:other rust SUNIONSTORE demo:all demo:tags demo:other ``` -------------------------------- ### PTTL Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/pttl.md Example showing how to set a key with a 60000 ms expiration and then read its remaining lifetime using PTTL. ```text SET demo:message hello PX 60000 PTTL demo:message ``` -------------------------------- ### Calling ArticleLikeMapper - usage example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/scenarios/article-likes.md Example of creating the mapper from a Session and invoking its methods. Starting with an empty set, first = 1, repeated = 0, count = 2, liked = 1, removed = 1; users contains u1001 and u1002 in no guaranteed order. Run inside the Session created in the 'about' page. ```java ArticleLikeMapper mapper = session.createMapper(ArticleLikeMapper.class); String key = "demo:likes:article:a1001"; int first = mapper.like(key, "u1001"); int repeated = mapper.like(key, "u1001"); mapper.like(key, "u1002"); long count = mapper.count(key); long liked = mapper.contains(key, "u1001"); List users = mapper.users(key); int removed = mapper.unlike(key, "u1001"); ``` -------------------------------- ### HVALS Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hvals.md Example showing HSET to create a hash and HVALS to read all values. Returns multiple rows of VALUE field, STRING type. ```text HSET demo:user name mali age 18 HVALS demo:user ``` -------------------------------- ### DEL Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/del.md Example showing how to set a key and then delete it using DEL. The SET command creates the key 'demo:message' with value 'hello', and DEL removes it. ```text SET demo:message hello DEL demo:message ``` -------------------------------- ### RPOP Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/rpop.md Example showing RPUSH to add elements to a queue and RPOP to pop two elements from the right end. ```text RPUSH demo:queue first second RPOP demo:queue 2 ``` -------------------------------- ### SDIFFSTORE Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/sdiffstore.md Example usage of SDIFFSTORE with SADD commands. Stores the set difference of demo:tags and demo:other into demo:diff. ```text SADD demo:tags java jdbc SADD demo:other java SDIFFSTORE demo:diff demo:tags demo:other ``` -------------------------------- ### SETEX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/setex.md Example usage of SETEX to set the key 'demo:message' with a value of 'hello' and an expiration of 60 seconds. Returns 1 if successful, 0 otherwise. ```text SETEX demo:message 60 hello ``` -------------------------------- ### SMISMEMBER Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/smismember.md Example usage: first adds members to a set, then checks membership for multiple members. ```text SADD demo:tags java jdbc SMISMEMBER demo:tags java rust ``` -------------------------------- ### SINTERCARD Example Commands Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/sintercard.md Example sequence: adds members to two sets, then counts intersection members with a limit of 10. ```text SADD demo:tags java jdbc SADD demo:other java SINTERCARD 2 demo:tags demo:other LIMIT 10 ``` -------------------------------- ### @SelectKeySql example: get auto-increment ID after INSERT Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/mapper/annotation_insert.mdx Executes additional SQL after INSERT to obtain the primary key and writes it back to the parameter object. Must be used together with @Insert. The order property is set to Order.After for auto-increment IDs. ```java @Insert({"insert into users (name, age, create_time)", "values (#{name}, #{age}, #{createTime})"}) @SelectKeySql(value = "select last_insert_id()", keyProperty = "id", order = Order.After) int saveUser(UserDTO user); UserDTO user = ...; mapper.saveUser(user); long newId = user.getId(); // Auto-increment ID has been written back ``` -------------------------------- ### SDIFF Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/sdiff.md Example usage: adds members to two sets and then applies SDIFF to get members in the first set not present in the second. ```text SADD demo:tags java jdbc SADD demo:other java SDIFF demo:tags demo:other ``` -------------------------------- ### INFO server Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/server/info.md Example usage of the INFO command with the 'server' section to retrieve server information. ```text INFO server ``` -------------------------------- ### PSETEX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/psetex.md Example usage of PSETEX to set the key 'demo:message' with a value of 'hello' and an expiration of 60000 milliseconds. Returns 1 if successful, 0 otherwise. ```text PSETEX demo:message 60000 hello ``` -------------------------------- ### GET /_cluster/... Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/elastic/admin/cluster.md Retrieves cluster status using the Elasticsearch cluster API. The example shows how to get cluster health. ```APIDOC ## [GET] /_cluster/... ### Description Get cluster status ### Method GET ### Endpoint /_cluster/... ### Request Example GET /_cluster/health ``` -------------------------------- ### LINDEX Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lindex.md Example showing how to use LINDEX after populating a list with RPUSH. The command returns the element at index 0, which is 'first'. ```text RPUSH demo:queue first second LINDEX demo:queue 0 ``` -------------------------------- ### GET /_cat/... Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/elastic/admin/cluster.md Retrieves cluster information using the Elasticsearch cat API. The example shows how to get node information. ```APIDOC ## [GET] /_cat/... ### Description Get cluster info ### Method GET ### Endpoint /_cat/... ### Request Example GET /_cat/nodes?v ``` -------------------------------- ### XML Mapping Example (UserMapper.xml) Source: https://github.com/zycgit/dbvisitor/blob/dev/README.en.md Shows an XML mapper with a select statement that can contain native SQL (MySQL) or JSON DSL (Elasticsearch) as comments. The DSL example is commented out. ```xml ``` -------------------------------- ### Custom RowCallbackHandler Implementation Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/result/row_callback.md Example implementation that collects names from each row into a list. Note that memory usage grows with row count, so it is not suitable for large-volume consumption. ```java public class UserRowCallbackHandler implements RowCallbackHandler { private final List names = new ArrayList<>(); @Override public void processRow(ResultSet rs, int rowNum) throws SQLException { names.add(rs.getString("name")); } public List getNames() { return names; } } ``` -------------------------------- ### LPUSHX Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lpushx.md Demonstrates using RPUSH to create a list and then LPUSHX to push an element onto its left end. The result is the length of the list after the push operation. ```text RPUSH demo:queue first LPUSHX demo:queue second ``` -------------------------------- ### Create user_info table for transaction example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/db2/transactions.mdx Creates the user_info table with an integer primary key id and a name column. Used as the starting point for the transaction examples. ```sql CREATE TABLE user_info ( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(100) ); ``` -------------------------------- ### SETNX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/setnx.md Example usage of SETNX to set a key only if it does not exist. Returns 1 if the key was set, 0 otherwise. ```text SETNX demo:new-message hello ``` -------------------------------- ### SHOW TABLES command Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/drivers/milvus/sql-client.mdx Executes the complete command to list collections in the current database. An empty database returns an empty list. For SQL and vector-search syntax, see the Command Reference. ```text SHOW TABLES; ``` -------------------------------- ### SADD Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/sadd.md Example usage of SADD adding members 'java' and 'jdbc' to the set 'demo:tags'. ```text SADD demo:tags java jdbc ``` -------------------------------- ### PEXPIREAT Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/pexpireat.md Example usage: sets a key and then applies an expiration timestamp. Returns 1 if the timeout was set, 0 otherwise. ```text SET demo:message hello PEXPIREAT demo:message 2000000000000 ``` -------------------------------- ### LLEN Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/llen.md Example showing how to use LLEN after pushing elements to a list. The result is a ResultSet with one row and a LONG type RESULT field. ```text RPUSH demo:queue first second LLEN demo:queue ``` -------------------------------- ### MSETNX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/msetnx.md Example usage of MSETNX with two key-value pairs. Returns 0 if any key already exists, otherwise returns the number of keys set. ```text MSETNX demo:new-name mali demo:new-city Shanghai ``` -------------------------------- ### Get indexes on orders Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-mongo/src/test/resources/mongo_tests/collection_commands.txt Returns a list of all indexes on the orders collection. ```javascript db.orders.getIndexes() ``` -------------------------------- ### MOVE Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/server/move.md Example usage: sets a key and moves it to database 1. Returns 1 if the key was moved, 0 otherwise. ```text SET demo:message hello MOVE demo:message 1 ``` -------------------------------- ### LPUSH Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lpush.md Example usage of LPUSH pushing two elements onto the list 'demo:queue'. The result is the length of the list after the push operation. ```text LPUSH demo:queue first second ``` -------------------------------- ### Example JDBC URL with local host and port Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/drivers/elastic/sql-client.mdx Example resulting JDBC URL when using the template with host 127.0.0.1 and port 9200. These examples target local, non-TLS services; do not put passwords or tokens in URLs. ```text jdbc:dbvisitor:elastic://127.0.0.1:9200 ``` -------------------------------- ### BLPOP Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/blpop.md Example that inserts elements before waiting. With data, returns two ELEMENT rows: the key name first, then the element. Empty-queue timeouts can currently fail; use a Redis client for reliable timeout handling. ```text RPUSH demo:queue first second BLPOP demo:queue 1 ``` -------------------------------- ### SHOW TABLES / TABLE / CREATE TABLE SQL examples Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/milvus/show/tables.md Use these SQL statements to list collections, inspect fields, or view the create table statement. SHOW TABLES lists collection names; SHOW TABLE returns one row per field with type, dimension, primary-key, AutoID, nullable, ARRAY element type/capacity, VARCHAR length, and partition/clustering-key flags; SHOW CREATE TABLE returns a CREATE SCRIPT (VARCHAR) with a CREATE TABLE statement, excluding indexes and permissions. ```sql SHOW TABLES; -- List all tables SHOW TABLE table_name; -- Inspect fields SHOW CREATE TABLE table_name; -- View detailed create table statement ``` -------------------------------- ### Get collection statistics Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-mongo/src/test/resources/mongo_tests/collection_commands.txt Returns statistics about the orders collection, such as size and document count. ```javascript db.orders.stats() ``` -------------------------------- ### Count documents in index Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-elastic/src/test/resources/elastic_tests/operation_types.txt Sends a POST request to /index/_count to get the number of documents in the index. ```http POST /index/_count ``` -------------------------------- ### Start Hasor with AutoConfigModule Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/yourproject/with_hasor.mdx Creates the AppContext, configures dbVisitor, and registers mappers. Then retrieves the service instance. ```java // Create the data source, configure dbVisitor, and register mappers AppContext appContext = Hasor.create().mainSettingWith("jdbc.properties").build(binder -> { binder.installModule(new AutoConfigModule()); }); // Enjoy ServiceTest service = appContext.getInstance(ServiceTest.class); ... ``` -------------------------------- ### SHOW IMPORT / IMPORTS example queries Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/milvus/show/import.md Example queries for SHOW IMPORT, SHOW PROGRESS OF IMPORT, and SHOW IMPORTS. Bind the job ID as a string. Connect to the service that owns the job. List pagination depends on the server REST version. ```sql SHOW IMPORT ?; SHOW PROGRESS OF IMPORT ?; SHOW IMPORTS FROM docs WITH (page_size=20,current_page=1); ``` -------------------------------- ### SREM Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/srem.md Example usage: first adds members 'java' and 'jdbc' to the set 'demo:tags', then removes 'java' from it. ```text SADD demo:tags java jdbc SREM demo:tags java ``` -------------------------------- ### BLMPOP Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/blmpop.md Example that inserts elements into a list with RPUSH before waiting and popping with BLMPOP. The command pops up to 2 elements from the left of demo:queue with a 1-second timeout. ```text RPUSH demo:queue first second BLMPOP 1 1 demo:queue LEFT COUNT 2 ``` -------------------------------- ### PERSIST Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/persist.md Sets a key with a 60-second expiration, then removes that expiration using PERSIST. The example demonstrates the command in a typical workflow. ```text SET demo:message hello EX 60 PERSIST demo:message ``` -------------------------------- ### BZMPOP Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/sorted-set/bzmpop.md Example usage: first adds members to a sorted set, then pops up to 2 members with the lowest scores from the first nonempty key. Note: when all source sets are empty or a blocking call times out, the current driver can fail rather than reliably return an empty ResultSet. ```text ZADD demo:ranking 10 alice 20 bob ``` ```text BZMPOP 1 1 demo:ranking MIN COUNT 2 ``` -------------------------------- ### Get index settings Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-elastic/src/test/resources/elastic_tests/index_management.txt Retrieves the current settings of 'my_index' using the _settings endpoint. ```http GET /my_index/_settings ``` -------------------------------- ### SMOVE example with SADD Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/set/smove.md Example showing how to add members to a set and then move one member to another set using SMOVE. ```text SADD demo:tags java jdbc SMOVE demo:tags demo:other java ``` -------------------------------- ### RENAMENX Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/renamenx.md Example usage: sets a key and then renames it with RENAMENX. Returns 1 if renamed, 0 if target key already exists. ```text SET demo:original hello RENAMENX demo:original demo:new-name ``` -------------------------------- ### SET command example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/set.md Example usage of the SET command: first sets a key with a 60-second expiration, then overwrites it conditionally with XX and GET while keeping the TTL. The second command returns the previous value in the VALUE field. ```text SET demo:message hello EX 60 SET demo:message world XX GET KEEPTTL ``` -------------------------------- ### PEXPIRE Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/pexpire.md Example showing how to set a key's lifetime in milliseconds. The SET command creates the key, then PEXPIRE sets its expiration to 60000 ms. ```text SET demo:message hello ``` ```text PEXPIRE demo:message 60000 ``` -------------------------------- ### Create user_info table Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/oracle/transactions.mdx Creates the user_info table with id as primary key. Used as the starting point for the transaction examples. ```sql CREATE TABLE user_info ( id NUMBER(10) PRIMARY KEY, name VARCHAR2(100) ); ``` -------------------------------- ### Transaction Control via @Tran Annotation Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/yourproject/with_solon.mdx Use the @Tran annotation from Solon to control transactions. The example uses TranPolicy.required. ```java import org.noear.solon.data.annotation.Tran; public class TxExample { @Tran(policy = TranPolicy.required) public void exampleMethod() throws SQLException { ... } } ``` -------------------------------- ### SCAN Example with SET and SCAN Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/keys/scan.md Example showing how to set a key and then scan for keys matching a pattern with a count hint and type filter. Note that the cursor is attached to result rows, so empty batches lose the continuation cursor, and COUNT may truncate a batch. ```text SET demo:message hello ``` ```text SCAN 0 MATCH demo:* COUNT 10 TYPE string ``` -------------------------------- ### RPOPLPUSH Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/rpoplpush.md Example showing how to use RPOPLPUSH to move the tail element from demo:queue to demo:processing. The RPUSH command populates the source list with two elements. ```text RPUSH demo:queue first second RPOPLPUSH demo:queue demo:processing ``` -------------------------------- ### Create user_info table for backfill examples Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/oracle/backfill.mdx Defines the table used by all backfill examples on this page. The database converts the name to uppercase during insertion. ```sql CREATE TABLE user_info ( id NUMBER(10) PRIMARY KEY, name VARCHAR2(100), age NUMBER(3) ); ``` -------------------------------- ### LambdaTemplate with Connection Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/api/lambda.md Creates a LambdaTemplate from a JDBC Connection and runs the same query as the DataSource example. Use when you already have a Connection object. ```java Connection conn = ...; LambdaTemplate lambda = new LambdaTemplate(conn); List users = lambda.query(User.class) .eq(User::getStatus, "ACTIVE") .ge(User::getAge, 18) .queryForList(); ``` -------------------------------- ### HSETNX Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hsetnx.md Example usage of HSETNX. Returns 0 if the field already exists; returns 1 if a new field was created. ```text HSETNX demo:user name mali ``` -------------------------------- ### Get distinct status values with price filter Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-adapter/jdbc-mongo/src/test/resources/mongo_tests/collection_commands.txt Returns distinct values of the 'status' field for documents where price is greater than 10. ```javascript db.orders.distinct("status", { price: { $gt: 10 } }) ``` -------------------------------- ### RPUSH Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/rpush.md Example usage of RPUSH to push two elements onto the list 'demo:queue'. Returns the length of the list after the push operation. ```text RPUSH demo:queue first second ``` -------------------------------- ### INCRBY example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/incrby.md Example showing how to use INCRBY after setting an initial counter value with SET. The first command sets the counter to 10, the second increments it by 5. ```text SET demo:counter 10 INCRBY demo:counter 5 ``` -------------------------------- ### Custom RowMapper Implementation (UserRowMapper) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/result/for_mapper.md Example implementation of RowMapper that maps a ResultSet row to a User object by reading columns 'id' and 'name'. ```java public class UserRowMapper implements RowMapper { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); return user; } } ``` -------------------------------- ### Parameterized Milvus query with PreparedStatement Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/drivers/sql-client.mdx Java example showing how to use PreparedStatement with a parameterized query for Milvus. Connection properties and SQL placeholders are separate; the common layer supplies values through AdapterRequest.getArgMap(). The adapter must pass them to the target database with appropriate types. Distinguish placeholders from question marks inside strings or comments, consume parameters in occurrence order, and check for missing values and unsupported types. Prefer native SDK binding. ```java try (PreparedStatement stmt = conn.prepareStatement( "SELECT id, title FROM intro_articles WHERE category = ? LIMIT 10")) { stmt.setString(1, "java"); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { System.out.println(rs.getLong("id") + ": " + rs.getString("title")); } } } ``` -------------------------------- ### Omit array for single argument (Example 3) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md When only one argument is used, the array can be omitted and the value passed directly to `queryForList`. ```java jdbcTemplate.queryForList("select * from users where id > ?", 2); ``` -------------------------------- ### Custom PreparedStatement Setup with RowCallbackHandler Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/jdbc/callback.mdx Sets arguments and processes rows via RowCallbackHandler. The example prepares a statement with a parameter and sets it to 2. ```java jdbc.executeCreator(con -> { PreparedStatement ps = con.prepareStatement("select * from users where id > ?"); ps.setInt(1, 2); return ps; }, (RowCallbackHandler) (rs, rowNum) -> { // process one row }); ``` -------------------------------- ### MGET Example with MSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/string/mget.md Example usage: first sets two keys with MSET, then reads them with MGET. The result is a ResultSet with multiple rows, each containing KEY and VALUE fields of STRING type. ```text MSET demo:name mali demo:city Shanghai MGET demo:name demo:city ``` -------------------------------- ### Custom PreparedStatement Setup with RowMapper Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/jdbc/callback.mdx Sets arguments and reads results via RowMapper. The example prepares a statement with a parameter and sets it to 2. ```java List result = jdbc.executeCreator(con -> { PreparedStatement ps = con.prepareStatement("select * from users where id > ?"); ps.setInt(1, 2); return ps; }, (RowMapper) (rs, rowNum) -> { return ...; }); ``` -------------------------------- ### Vector Search SQL Examples (KNN, Pre-filtering, Range Search) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/milvus/query/select.md Use the `<->` operator or `vector_range` function for vector distance calculation. The examples show basic KNN search with default parameters, pre-filtering with a scalar predicate, and two methods for range search/distance filtering. The `vector_range` function is recommended for range search. ```sql -- Basic Search (KNN, default params) SELECT * FROM table_name ORDER BY vector_col <-> [0.1, 0.2] LIMIT 10; -- Search with pre-filtering SELECT * FROM table_name WHERE category = 'book' ORDER BY vector_col <-> [0.1, 0.2] LIMIT 5; -- Range Search / Distance Filtering -- Method 1: Using vector_range function (Recommended) SELECT * FROM table_name WHERE vector_range(vector_col, [0.1, 0.2], 0.8) LIMIT 5; -- Method 2: Using comparison expression (WHERE vector_col <-> [vector] < distance_threshold) SELECT * FROM table_name WHERE vector_col <-> [0.1, 0.2] < 0.8 LIMIT 5; ``` -------------------------------- ### Custom PreparedStatement Setup with ResultSetExtractor Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/jdbc/callback.mdx Sets arguments and reads results via ResultSetExtractor. The example prepares a statement with a parameter and sets it to 2. ```java T result = jdbc.executeCreator(con -> { PreparedStatement ps = con.prepareStatement("select * from users where id > ?"); ps.setInt(1, 2); return ps; }, (ResultSetExtractor) rs -> { return ...; }); ``` -------------------------------- ### ViewCounterMapper.java - Redis INCR and GET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/scenarios/view-counter.md Defines a SimpleMapper interface for incrementing and reading a Redis counter. INCR returns the new value, so @Query is used instead of interpreting it as an update count. GET returns null for a missing key; INCR starts from zero when the key is missing. ```java package com.example.redis; import net.hasor.dbvisitor.mapper.Param; import net.hasor.dbvisitor.mapper.Query; import net.hasor.dbvisitor.mapper.SimpleMapper; @SimpleMapper public interface ViewCounterMapper { @Query("INCR #{key}") long increment(@Param("key") String key); @Query("GET #{key}") Long count(@Param("key") String key); } ``` -------------------------------- ### HMGET Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hmget.md Example showing how to set a hash with HSET and then read multiple fields with HMGET. The result returns one row per requested field in argument order, with missing fields as null. ```text HSET demo:user name mali age 18 HMGET demo:user age name ``` -------------------------------- ### RPUSHX Example Usage Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/rpushx.md Demonstrates using RPUSHX after an RPUSH command. The RPUSH creates the list 'demo:queue' with 'first', then RPUSHX appends 'second' to the existing list. ```text RPUSH demo:queue first RPUSHX demo:queue second ``` -------------------------------- ### SQL count rewrite example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/lambda/query.md Shows the original query and the rewritten count query generated by dbVisitor's dialect support. The original query is wrapped in a subquery and counted with `count(*)`. ```sql -- original query select id, name from users where id <= 100; -- rewritten as count query select count(*) from (select id, name from users where id <= 100) as TEMP_T; ``` -------------------------------- ### ZMPOP Example with ZADD Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/sorted-set/zmpop.md Example showing ZADD to create a sorted set and ZMPOP to pop the two lowest-score members. Note: when all source sets are empty, the driver may fail instead of returning an empty ResultSet. ```text ZADD demo:ranking 10 alice 20 bob ``` ```text ZMPOP 1 demo:ranking MIN COUNT 2 ``` -------------------------------- ### Use SqlArg to specify TypeHandler (Example 1) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md Use `SqlArg.valueOf` with a TypeHandler to control how arguments are set. `LongTypeHandler` sets a Long argument, `StringTypeHandler` sets a String argument. ```java SqlArg[] args = new SqlArg[] { SqlArg.valueOf(2L, new LongTypeHandler()), // LongTypeHandler sets a Long argument SqlArg.valueOf("Dave", new StringTypeHandler())// StringTypeHandler sets a String argument }; jdbcTemplate.queryForList("select * from users where id > ? and name = ?", args); ``` -------------------------------- ### queryForObject Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/dbvisitor/jdbc.md Reads a scalar value using a Redis command as query text. For example, `queryForObject("GET ?", key, String.class)` reads a string value for a given key. ```APIDOC ## queryForObject ### Description Reads a scalar value using a Redis command as query text. For example, `queryForObject("GET ?", key, String.class)` reads a string value for a given key. ``` -------------------------------- ### ZUNION Example with ZADD and ZUNION Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/sorted-set/zunion.md Example showing how to use ZUNION with two source keys, weights, and AGGREGATE MAX. The ZADD commands set up the source sets, and ZUNION returns a ResultSet with ELEMENT and SCORE fields (when WITHSCORES is used). ```text ZADD demo:ranking 10 alice 20 bob ``` ```text ZADD demo:other 30 alice ``` ```text ZUNION 2 demo:ranking demo:other WEIGHTS 1 2 AGGREGATE MAX WITHSCORES ``` -------------------------------- ### ZDIFF Example with ZADD Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/sorted-set/zdiff.md Example showing how to use ZDIFF with WITHSCORES. First, two sorted sets are created with ZADD, then ZDIFF returns the difference between the first set and the others. ```text ZADD demo:ranking 10 alice 20 bob ``` ```text ZADD demo:other 30 alice ``` ```text ZDIFF 2 demo:ranking demo:other WITHSCORES ``` -------------------------------- ### LambdaTemplate queryForCount example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/lambda/query.md Uses `LambdaTemplate.query` with `le` to match `id <= 100` and `queryForCount` to return an int count. `queryForLargeCount` is commented out as an alternative for long counts. Choose based on size needs. ```java LambdaTemplate lambda = ...; RowMapper rowMapper = new BeanMappingRowMapper(UserVO.class); int count = lambda.query(User.class) .le(User::getId, 100) // match id <= 100 .queryForCount(); // count as int //.queryForLargeCount(); // count as long ``` -------------------------------- ### HKEYS Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hkeys.md Example usage: sets a hash field and then lists its field names. The result is a ResultSet with multiple rows of FIELD type and STRING content. ```text HSET demo:user name mali age 18 HKEYS demo:user ``` -------------------------------- ### HGETALL Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hgetall.md Example usage: first sets a hash with HSET, then retrieves all fields and values with HGETALL. Returns a ResultSet with multiple rows, each containing FIELD and VALUE entries of STRING type. ```text HSET demo:user name mali age 18 HGETALL demo:user ``` -------------------------------- ### Mix SqlArg and plain values in Map (Example 2) Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/args/position.md SqlArg objects can be placed directly in a Map as named argument values. The framework automatically recognizes and uses their type information. ```java Map args = new HashMap<>(); args.put("id", SqlArg.valueOf(2L, new LongTypeHandler())); args.put("name", "Dave"); jdbcTemplate.queryForList("select * from users where id > :id and name = :name", args); ``` -------------------------------- ### @Insert example: insert a user record Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/mapper/annotation_insert.mdx Marks a method to execute an INSERT statement. The value supports string arrays joined with spaces for multi-line writing. The method returns the number of affected rows. ```java @SimpleMapper public interface UserMapper { @Insert({"insert into users (", " id, name, age, create_time", ") values (", " #{id}, #{name}, #{age}, #{createTime}", ")"}) int saveUser(UserDTO user); } ``` -------------------------------- ### Create user_info table and insert Alice Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/db2/conflict.mdx SQL setup for the conflict example. Creates the user_info table with id as primary key and inserts an existing row for Alice (id 1001). ```sql CREATE TABLE user_info ( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(64), age INTEGER ); INSERT INTO user_info (id, name, age) VALUES (1001, 'Alice', 18); ``` -------------------------------- ### HPTTL Example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hpttl.md Example sequence showing how to set a field, set its expiration, and then read the remaining lifetime. The commands are executed in order: HSET creates the field, HPEXPIRE sets a 60000 ms expiration, and HPTTL reads the remaining time. ```text HSET demo:user name mali ``` ```text HPEXPIRE demo:user 60000 FIELDS 1 name ``` ```text HPTTL demo:user FIELDS 1 name ``` -------------------------------- ### WAIT Example with SET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/server/wait.md Example usage: sets a message then waits for one replica acknowledgment with a 1-second timeout. Returns a ResultSet with one row containing a REPLICAS field of LONG type. ```text SET demo:message hello WAIT 1 1000 ``` -------------------------------- ### Create table and sequence for Oracle generated keys Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/oracle/generated-keys.mdx Defines the user_info table with a NUMBER primary key and a sequence user_info_seq starting at 1, incrementing by 1. Required before using any of the sequence-based insert examples. ```sql CREATE TABLE user_info ( id NUMBER(10) PRIMARY KEY, name VARCHAR2(100), age NUMBER(3) ); CREATE SEQUENCE user_info_seq START WITH 1 INCREMENT BY 1; ``` -------------------------------- ### Using BaseMapper CRUD and Builder API Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/api/mapper.md Creates a Mapper instance via session.createMapper and performs zero-SQL CRUD. Switches to the Builder API with mapper.query() when conditions get complex, using methods like likeRight and ge. ```java UserMapper mapper = session.createMapper(UserMapper.class); // Zero-SQL CRUD mapper.insert(user); User u = mapper.selectById(1L); List users = mapper.listBySample(sample); // Switch to Builder API when conditions get complex List result = mapper.query() .likeRight(User::getName, "A") .ge(User::getAge, 18) .queryForList(); ``` -------------------------------- ### HGET Example with HSET Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/hash/hget.md Example usage: first set a hash field with HSET, then read it with HGET. The result is a ResultSet with one row containing the VALUE field of STRING type. ```text HSET demo:user name mali ``` ```text HGET demo:user name ``` -------------------------------- ### AND + IN nested rule example with generated SQL Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/rules/nested_rule.mdx Nests the in rule inside the and rule because the in rule does not automatically add AND/OR prefixes. The first block shows the query with the nested rule; the second block shows the generated SQL when ids=[1,2,3]. ```sql select * from users where status = :status @{and, id IN @{in, :ids}} ``` ```sql select * from users where status = ? and id IN (?, ?, ?) ``` -------------------------------- ### @Execute example: create a sharded table Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/mapper/annotation_execute.mdx Marks an interface method to execute any SQL statement (DML/DDL). The value supports string arrays joined with spaces for multi-line writing. Uses ${part} string substitution (beware of SQL injection risks). ```java @SimpleMapper public interface UserMapper { @Execute({"create table users_${part} (", " id int primary key,", " name varchar(50)", ")"}) int newPartTable(@Param("part") int partId); } ``` -------------------------------- ### BaseMapper: Inherit CRUD methods and usage Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-blog/2026-01-13-dbvisitor-two-layer-adapter.md Extend BaseMapper to get standard CRUD operations without writing implementations. The framework auto-generates statements based on the generic entity T. The usage example shows insert and selectById. ```java // Just one inheritance to own a full set of CRUD methods public interface UserMapper extends BaseMapper { } // Usage userMapper.insert(new UserInfo("1001", "Tom")); UserInfo user = userMapper.selectById("1001"); ``` -------------------------------- ### @Call stored procedure example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/mapper/annotation_call.mdx Marks an interface method to execute a stored procedure call using CallableStatement. Input parameters are passed via method arguments; output parameters and result sets are received through the returned Map. Return type must be Map. ```java @SimpleMapper public interface UserMapper { // Input and output parameters @Call("{call proc_select_user(#{abc, mode=inout, jdbcType=decimal})}") Map callSelectUser1(@Param("abc") int argAbc); // Output-only parameter @Call("{call proc_select_user(#{abc, mode=out, jdbcType=decimal})}") Map callSelectUser2(); } UserMapper mapper = ...; Map res1 = mapper.callSelectUser1(23); res1.get("abc"); // Get the INOUT parameter Map res2 = mapper.callSelectUser2(); res2.get("abc"); // Get the OUT parameter ``` -------------------------------- ### LPOP Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lpop.md Example workflow: first pushes two elements onto the list 'demo:queue' with RPUSH, then pops up to 2 elements from the left end using LPOP. The result is a ResultSet with multiple rows, each containing an ELEMENT field of STRING type. ```text RPUSH demo:queue first second LPOP demo:queue 2 ``` -------------------------------- ### LambdaTemplate streaming with RowCallbackHandler Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/core/lambda/query.md Processes each row without collecting the result set using a `RowCallbackHandler`. The handler's `processRow` method is called for each row; the example shows the method signature and a placeholder body. The query uses `eq` to match `id = 100` and passes the handler to `query`. ```java RowCallbackHandler handler = new RowCallbackHandler() { @Override public void processRow(ResultSet rs, int rowNum) throws SQLException { ... } }; LambdaTemplate lambda = ...; lambda.query(User.class) .eq(User::getId, 100) // match id = 100 .query(handler); // process via RowCallbackHandler ``` -------------------------------- ### Create user_info table and sequence for sequence strategy Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/db2/generated-keys.mdx SQL DDL for a table with a regular primary key and a sequence, used for the sequence key strategy examples. ```sql CREATE TABLE user_info ( id BIGINT NOT NULL PRIMARY KEY, name VARCHAR(64) ); CREATE SEQUENCE user_info_seq START WITH 1 INCREMENT BY 1; ``` -------------------------------- ### AND + MD5 nested rule example Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/guides/rules/nested_rule.mdx Nests the md5 rule inside the and rule to hash a parameter and generate a placeholder. The inner rule executes first, producing a SQL parameter placeholder, then the outer rule splices it into the final SQL. Note: MD5 is only for existing fields, not for new password storage. ```sql -- Original parameter :pwd = '123456' @{and, password = @{md5, :pwd}} ``` -------------------------------- ### MongoDB-style command examples with database and collection prefixes Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/mongo/basics/commands.md Shows MongoDB-style method calls without rewriting them as SQL. `db` refers to the current database; omitting the database prefix also uses the current database. If none is selected in the URL, execute `use test` first or use `test.user_info` explicitly. ```text use test; db.user_info.find({name: ?}); user_info.find({name: ?}); test.user_info.find({name: ?}); ``` -------------------------------- ### LRANGE Example with RPUSH Source: https://github.com/zycgit/dbvisitor/blob/dev/dbvisitor-doc/i18n/en/docusaurus-plugin-content-docs/current/features/redis/list/lrange.md Example sequence: first pushes two elements to a list with RPUSH, then reads elements at indices 0 and 1 with LRANGE. The result is a ResultSet with multiple rows. ```text RPUSH demo:queue first second LRANGE demo:queue 0 1 ```