Package org.fastnate.generator.provider
Interface JpaProvider
public interface JpaProvider
Encapsulates details specific to the current JPA implementation.
- Author:
- Tobias Liefke
-
Method Summary
Modifier and TypeMethodDescriptiondefault <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.static voidcopySetting(Properties settings, String providerProperty, String fastnateProperty) Copies a JPA provider specific property to the matching Fastnate property, if it is not set already.default <T> ValueConverter<T> createBasicConverter(String attributeName, Class<T> targetType) Creates a converter for a primitive database type.default <T> ValueConverter<T> createConverter(AttributeAccessor attribute, Class<T> targetType, boolean mapKey) Creates a converter for an attribute that has aPrimitiveProperty.default <T> ValueConverter<T> createFallbackConverter(String attributeName, Class<T> targetType) Creates the converter for a type that is unknown to us.jakarta.persistence.GenerationTypegetAutoGenerationType(GeneratorDialect dialect) Resolves the generation type to use, ifGenerationType.AUTOis specified in the model.The name of the default generatorTableGenerator.table(), if none was specified for a table generator.The name of the default generatorTableGenerator.pkColumnName(), if none was specified for a table generator.default StringgetDefaultGeneratorTablePkColumnValue(String tableName) The name of the default generatorTableGenerator.pkColumnValue(), if none was specified for a table generator.The name of the default generatorTableGenerator.valueColumnName(), if none was specified for a table generator.getDefaultSequence(String tableName) The name of the defaultsequence, if none was specified for a sequence generator.default voidinitialize(Properties settings) Initializes this provider from the given settings.default booleanIndicates that this JPA implementation initializes theTableGeneratortables when the schema is created.booleanIndicates if the current JPA provider needs always a discriminator column for a JOINED table.default booleanisPersistent(AttributeAccessor attribute) Indicates that the given attribute is persistent according to the current JPA provider.
-
Method Details
-
copySetting
Copies a JPA provider specific property to the matching Fastnate property, if it is not set already.- Parameters:
settings- the current settingsproviderProperty- the name of the property for the JPA providerfastnateProperty- 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 classpropertyTable- the table of the new propertyattribute- the attribute to inspectsurroundingAttributeOverrides- the overrides defined for the surrounding elementsurroundingAssociationOverrides- the overrides defined for the surrounding element- Returns:
- the property that represents the attribute or
nullif the attribute not persistent
-
createBasicConverter
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 errortargetType- the primitive database type- Returns:
- the converter or an instance of
UnsupportedTypeConverterif 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 aPrimitiveProperty.- 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 typetargetType- the type of the valuemapKey- indicates that the converter is for the key of a map- Returns:
- the converter or an instance of
UnsupportedTypeConverterif no converter is available
-
createFallbackConverter
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 errortargetType- the primitive database type- Returns:
- the converter or an instance of
UnsupportedTypeConverterif no converter is available
-
getAutoGenerationType
Resolves the generation type to use, ifGenerationType.AUTOis 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 generatorTableGenerator.table(), if none was specified for a table generator.- Returns:
- the default generator table
-
getDefaultGeneratorTablePkColumnName
String getDefaultGeneratorTablePkColumnName()The name of the default generatorTableGenerator.pkColumnName(), if none was specified for a table generator.- Returns:
- the default primary column name for the generator table
-
getDefaultGeneratorTablePkColumnValue
The name of the default generatorTableGenerator.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 generatorTableGenerator.valueColumnName(), if none was specified for a table generator.- Returns:
- the default value column name for the generator table
-
getDefaultSequence
The name of the defaultsequence, if none was specified for a sequence generator.- Parameters:
tableName- the name of the current table- Returns:
- the default sequence name
-
initialize
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 theTableGeneratortables when the schema is created.- Returns:
falseif we need to use insert statement when allocating an ID the first time,trueif 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:
trueto always write a discriminator column,falseif it should be written only if explicitly given
-
isPersistent
Indicates that the given attribute is persistent according to the current JPA provider.- Parameters:
attribute- the attribute to check- Returns:
trueif the given attribute is written to the database
-