Interface JpaProvider


public interface JpaProvider
Encapsulates details specific to the current JPA implementation.
Author:
Tobias Liefke
  • Method Details

    • copySetting

      static void copySetting(Properties settings, String providerProperty, String fastnateProperty)
      Copies a JPA provider specific property to the matching Fastnate property, if it is not set already.
      Parameters:
      settings - the current settings
      providerProperty - the name of the property for the JPA provider
      fastnateProperty - the name of the property for Fastnate
    • buildProperty

      default <E, X> Property<X,?> buildProperty(EntityClass<E> entityClass, GeneratorTable propertyTable, AttributeAccessor attribute, Map<String,jakarta.persistence.AttributeOverride> surroundingAttributeOverrides, Map<String,jakarta.persistence.AssociationOverride> surroundingAssociationOverrides)
      Builds the property for the given attribute.
      Parameters:
      entityClass - the surrounding class
      propertyTable - the table of the new property
      attribute - the attribute to inspect
      surroundingAttributeOverrides - the overrides defined for the surrounding element
      surroundingAssociationOverrides - the overrides defined for the surrounding element
      Returns:
      the property that represents the attribute or null if the attribute not persistent
    • createBasicConverter

      default <T> ValueConverter<T> createBasicConverter(String attributeName, Class<T> targetType)
      Creates a converter for a primitive database type.
      Type Parameters:
      T - the generic type
      Parameters:
      attributeName - the name of the attribute that contains the value - only to print that name in case of any error
      targetType - the primitive database type
      Returns:
      the converter or an instance of UnsupportedTypeConverter if no converter is available
    • createConverter

      default <T> ValueConverter<T> createConverter(AttributeAccessor attribute, Class<T> targetType, boolean mapKey)
      Creates a converter for an attribute that has a PrimitiveProperty.
      Type Parameters:
      T - the generic binding of the type of the value
      Parameters:
      attribute - the accessor for the attribute that contains the value, not nessecarily of the target type
      targetType - the type of the value
      mapKey - indicates that the converter is for the key of a map
      Returns:
      the converter or an instance of UnsupportedTypeConverter if no converter is available
    • createFallbackConverter

      default <T> ValueConverter<T> createFallbackConverter(String attributeName, Class<T> targetType)
      Creates the converter for a type that is unknown to us. Should be overridden for any provider specific types.
      Type Parameters:
      T - the generic type
      Parameters:
      attributeName - the name of the attribute that contains the value - only to print that name in case of any error
      targetType - the primitive database type
      Returns:
      the converter or an instance of UnsupportedTypeConverter if no converter is available
    • getAutoGenerationType

      jakarta.persistence.GenerationType getAutoGenerationType(GeneratorDialect dialect)
      Resolves the generation type to use, if GenerationType.AUTO is specified in the model.
      Parameters:
      dialect - the current database dialect
      Returns:
      the matching generation type - not GenerationType.AUTO
    • getDefaultGeneratorTable

      String getDefaultGeneratorTable()
      The name of the default generator TableGenerator.table(), if none was specified for a table generator.
      Returns:
      the default generator table
    • getDefaultGeneratorTablePkColumnName

      String getDefaultGeneratorTablePkColumnName()
      The name of the default generator TableGenerator.pkColumnName(), if none was specified for a table generator.
      Returns:
      the default primary column name for the generator table
    • getDefaultGeneratorTablePkColumnValue

      default String getDefaultGeneratorTablePkColumnValue(String tableName)
      The name of the default generator TableGenerator.pkColumnValue(), if none was specified for a table generator.
      Parameters:
      tableName - the name of the current table
      Returns:
      the default primary column value for the generator table
    • getDefaultGeneratorTableValueColumnName

      String getDefaultGeneratorTableValueColumnName()
      The name of the default generator TableGenerator.valueColumnName(), if none was specified for a table generator.
      Returns:
      the default value column name for the generator table
    • getDefaultSequence

      String getDefaultSequence(String tableName)
      The name of the default sequence, if none was specified for a sequence generator.
      Parameters:
      tableName - the name of the current table
      Returns:
      the default sequence name
    • initialize

      default void initialize(Properties settings)
      Initializes this provider from the given settings. May as well change the settings according to some other settings found.
      Parameters:
      settings - the settings of the generator context
    • isInitializingGeneratorTables

      default boolean isInitializingGeneratorTables()
      Indicates that this JPA implementation initializes the TableGenerator tables when the schema is created.
      Returns:
      false if we need to use insert statement when allocating an ID the first time, true if we always can just update the ID
    • isJoinedDiscriminatorNeeded

      boolean isJoinedDiscriminatorNeeded()
      Indicates if the current JPA provider needs always a discriminator column for a JOINED table.
      Returns:
      true to always write a discriminator column, false if it should be written only if explicitly given
    • isPersistent

      default boolean isPersistent(AttributeAccessor attribute)
      Indicates that the given attribute is persistent according to the current JPA provider.
      Parameters:
      attribute - the attribute to check
      Returns:
      true if the given attribute is written to the database