vendor

Talks about: , and

The vendor name of the database the SQL statement is intended for

Where one query cannot be written for every database you support, write one statement per database and give them the same name . They become a single method that picks its statement from the connection at run time.

The value is matched against the JDBC driver’s own DatabaseMetaData.getDatabaseProductName(), so it has to be exactly what the driver reports — PostgreSQL, MySQL, H2, Microsoft SQL Server, Oracle. A statement of the same name without a vendor is the fallback for every database not named, and a name with no fallback fails against a database none of its statements claim.

Nothing here inspects your SQL. Naming a vendor selects a statement; it does not translate one.

Configuration Options

Option: ‘PostgreSQL’

Statements sharing a name become one method that chooses between them:

public final class TenantRepository {

    public List<Tenant> findTenants() {
        try (final var connection = dataSource.getConnection()) {
            final var databaseMetaData = connection.getMetaData();
            final var databaseProductName = databaseMetaData.getDatabaseProductName();
            String query = null;
            switch (databaseProductName) {
              case "PostgreSQL":
                query = FIND_TENANTS_POSTGRE_SQL;
                break;
              default:
                query = FIND_TENANTS;
                break;
            }
            // ... rest of generated code
        }
    }

}

Also in this group: annotations , catchAndRethrow , createConnection , description , executeBatch , executeOnce , generateConnectionOverloads , generateResultRowType , injectConverter , name , parameters , repository , resultRowColumns , resultRowConverter , resultRowType , returningMode , throwOnMultipleResults , type , validateSchema , writesReturnUpdateCount .

Front Matter

In order to configure this option, place the following code in the front matter of your SQL statement:

-- vendor: PostgreSQL
SELECT  something
FROM    your_database_schema
WHERE   some_column = :some_value