Package st.orm

Class StormConfig

java.lang.Object
st.orm.StormConfig

public final class StormConfig extends Object
Immutable, untyped configuration for the Storm ORM framework.

A StormConfig holds an immutable set of String key-value properties. Property keys use the same names as the corresponding JVM system properties (e.g. storm.update.default_mode). When a requested key is not present in the property map, the lookup falls back to System.getProperty(String), so existing JVM flag users are unaffected.

Usage

Programmatic configuration:


 StormConfig config = StormConfig.of(Map.of(
     StormConfig.UPDATE_DEFAULT_MODE, "FIELD",
     StormConfig.UPDATE_MAX_SHAPES, "10"
 ));
 ORMTemplate orm = ORMTemplate.of(dataSource, config);
 

When no configuration is provided, ORMTemplate.of(dataSource) uses defaults(), which reads exclusively from system properties.

Since:
1.9
  • Field Details

    • UPDATE_DEFAULT_MODE

      public static final String UPDATE_DEFAULT_MODE
      Default update mode for entities without @DynamicUpdate. Values: ENTITY, FIELD, OFF.
      See Also:
    • UPDATE_DIRTY_CHECK

      public static final String UPDATE_DIRTY_CHECK
      Default dirty check strategy. Values: INSTANCE, VALUE.
      See Also:
    • UPDATE_MAX_SHAPES

      public static final String UPDATE_MAX_SHAPES
      Maximum UPDATE shapes before fallback to full-row update.
      See Also:
    • ENTITY_CACHE_RETENTION

      public static final String ENTITY_CACHE_RETENTION
      Cache retention mode. Values: default, light.
      See Also:
    • IN_LIST

      public static final String IN_LIST
      How an IN list renders. Values: auto, one array parameter where the dialect binds one, so the statement does not change with the length of the list, and one placeholder per value elsewhere; padded, one placeholder per value on every dialect, padded to the next power of two by repeating the last value, for a database whose plan cache fills with the lengths; exact, one placeholder per value everywhere. Defaults to auto.
      Since:
      1.16
      See Also:
    • TEMPLATE_CACHE_SIZE

      public static final String TEMPLATE_CACHE_SIZE
      Maximum number of compiled templates to cache.
      See Also:
    • ANSI_ESCAPING

      public static final String ANSI_ESCAPING
      Whether to use ANSI escaping for identifiers.
      See Also:
    • VALIDATION_RECORD_MODE

      public static final String VALIDATION_RECORD_MODE
      Record validation mode. Values: fail, warn, none.
      See Also:
    • VALIDATION_SCHEMA_MODE

      public static final String VALIDATION_SCHEMA_MODE
      Schema validation mode. Values: none, load, warn, fail; load loads the schema without validating it.
      See Also:
    • VALIDATION_STRICT

      public static final String VALIDATION_STRICT
      Whether to treat schema validation warnings as errors.
      See Also:
    • VALIDATION_INTERPOLATION_MODE

      public static final String VALIDATION_INTERPOLATION_MODE
      Interpolation safety mode. Values: warn, fail, none.
      See Also:
    • SQL_LOG_LINE_WIDTH

      public static final String SQL_LOG_LINE_WIDTH
      Display width performance log summary rows aim for, such as 120 for narrow viewers or 240 for wide ones; at least 80.
      See Also:
    • SQL_LOG_CALL_SITE_SKIP

      public static final String SQL_LOG_CALL_SITE_SKIP
      Comma-separated package prefixes or source file names skipped in SQL log call-site attribution.
      See Also:
    • SQL_LOG_SLOW_THRESHOLD

      public static final String SQL_LOG_SLOW_THRESHOLD
      Database time above which a single statement execution is reported under the st.orm.sql.slow logger, such as 200ms or 2s; a bare number is milliseconds. Unset means no slow log.
      See Also:
    • SQL_LOG_SLOW_LIMIT

      public static final String SQL_LOG_SLOW_LIMIT
      Slow statement lines reported per shape per minute before the rest are suppressed and counted; zero for no limit. Defaults to 5.
      See Also:
    • SQL_LOG_SLOW_TRANSACTION

      public static final String SQL_LOG_SLOW_TRANSACTION
      Time a transaction may hold its connection beyond what its statements spent on it, such as 2s; a transaction idle for longer is reported under the st.orm.sql.slow logger, with the call site that began it. Defaults to 1s; 0 stops watching transactions.
      Since:
      1.16
      See Also:
    • ADVICE_CATEGORIES

      public static final String ADVICE_CATEGORIES
      Comma-separated categories of advice the st.orm.sql.advice log reports: correctness, performance and design. Defaults to correctness; the Spring Boot and Ktor integrations add design and performance in development, as does the test extension.
      Since:
      1.16
      See Also:
    • ADVICE_ENTITY_BUDGET_JOINS

      public static final String ADVICE_ENTITY_BUDGET_JOINS
      The most tables the design budget lets an entity's read join, which design advice checks entities against. Defaults to 10; at least 1.
      Since:
      1.16
      See Also:
    • ADVICE_ENTITY_BUDGET_COLUMNS

      public static final String ADVICE_ENTITY_BUDGET_COLUMNS
      The most columns the design budget lets an entity's read select beyond its own, which design advice checks entities against. Defaults to 96; at least 1.
      Since:
      1.16
      See Also:
    • ADVICE_REPEAT_FLOOR

      public static final String ADVICE_REPEAT_FLOOR
      The time a repeated statement must have taken, on the clock, before it carries advice: the same single-row read or write run again and again, or references fetched one at a time, below it is not advised on. Defaults to 50ms; 0 advises on every repeat past ten executions.
      Since:
      1.16
      See Also:
  • Method Details

    • getProperty

      public @Nullable String getProperty(String key)
      Returns the value of the property with the given key.

      If the key is present in the property map, its value is returned. Otherwise, the value of the corresponding JVM system property is returned. If neither is set, null is returned.

      Parameters:
      key - the property key.
      Returns:
      the property value, or null if not set.
    • getProperty

      public String getProperty(String key, String defaultValue)
      Returns the value of the property with the given key, falling back to the specified default.
      Parameters:
      key - the property key.
      defaultValue - the default value to return if the property is not set.
      Returns:
      the property value, or defaultValue if not set.
    • of

      public static StormConfig of(Map<String,String> properties)
      Creates a new StormConfig with the given properties.
      Parameters:
      properties - the configuration properties; must not be null.
      Returns:
      a new immutable configuration.
    • defaults

      public static StormConfig defaults()
      Returns a configuration that reads exclusively from JVM system properties.

      This is the default configuration used when no explicit StormConfig is provided.

      Returns:
      the default configuration; never null.
    • sqlShapingKeys

      public static Set<String> sqlShapingKeys()
      Returns the keys of the properties that affect the shape of generated SQL.

      Two configurations that differ in any of these keys can generate different SQL for the same template, so caches of generated SQL must include the values of these keys in their cache keys. The set is derived from the key declarations in this class.

      Returns:
      the SQL-shaping property keys; never null.
      Since:
      1.14