Class HibernateDatabase

java.lang.Object
liquibase.database.AbstractJdbcDatabase
liquibase.ext.hibernate.database.HibernateDatabase
All Implemented Interfaces:
AutoCloseable, liquibase.database.Database, liquibase.servicelocator.PrioritizedService
Direct Known Subclasses:
HibernateClassicDatabase, HibernateEjb3Database, HibernateSpringBeanDatabase

public abstract class HibernateDatabase extends liquibase.database.AbstractJdbcDatabase
Base class for all Hibernate Databases. This extension interacts with Hibernate by creating standard liquibase.database.Database implementations that bridge what Liquibase expects and the Hibernate APIs.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    protected org.hibernate.dialect.Dialect
     

    Fields inherited from class liquibase.database.AbstractJdbcDatabase

    caseSensitive, currentDateTimeFunction, dateFunctions, defaultAutoIncrementBy, defaultAutoIncrementStartWith, defaultCatalogName, defaultSchemaName, quotingStrategy, sequenceCurrentValueFunction, sequenceNextValueFunction, unmodifiableDataTypes, unquotedObjectsAreUppercased

    Fields inherited from interface liquibase.servicelocator.PrioritizedService

    COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Perform any post-configuration setting logic.
    protected final org.hibernate.boot.Metadata
    Called by setConnection(DatabaseConnection) to create the Metadata stored in this database.
    protected org.hibernate.boot.Metadata
    Called by buildMetadata() when a CustomMetadataFactory is not configured.
    protected void
    configureImplicitNamingStrategy(String implicitNamingStrategy, org.hibernate.boot.MetadataBuilder builder)
     
    protected void
    configureMetadataBuilder(org.hibernate.boot.MetadataBuilder metadataBuilder)
    Called by buildMetadataFromPath() to do final configuration on the MetadataBuilder before MetadataBuilder.build() is called.
    protected void
    configurePhysicalNamingStrategy(String physicalNamingStrategy, org.hibernate.boot.MetadataBuilder builder)
     
    protected abstract void
    configureSources(org.hibernate.boot.MetadataSources sources)
    Adds any implementation-specific sources to the given MetadataSources
    protected org.hibernate.boot.MetadataSources
    Creates the base MetadataSources to use for this database.
    boolean
     
    protected String
    Called by createMetadataSources() to determine the correct dialect name based on url parameters, configuration files, etc.
    protected String
     
    protected String
     
     
     
     
     
    org.hibernate.dialect.Dialect
    Returns the dialect determined during database initialization.
    Convenience method to return the underlying HibernateConnection in the JdbcConnection returned by AbstractJdbcDatabase.getConnection()
    org.hibernate.boot.Metadata
    Return the hibernate Metadata used by this database.
    int
     
    Returns the value of the given property.
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    void
    setConnection(liquibase.database.DatabaseConnection conn)
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     

    Methods inherited from class liquibase.database.AbstractJdbcDatabase

    addReservedWords, canCreateChangeLogTable, close, commit, correctObjectName, correctSchema, correctSchema, dataTypeIsNotModifiable, disableForeignKeyChecks, doesTagExist, dropDatabaseObjects, enableForeignKeyChecks, equals, escapeColumnName, escapeColumnName, escapeColumnNameList, escapeConstraintName, escapeDataTypeName, escapeIndexName, escapeObjectName, escapeObjectName, escapeSequenceName, escapeStringForDatabase, escapeTableName, escapeViewName, execute, executeRollbackStatements, executeRollbackStatements, executeStatements, filterRollbackVisitors, generateAutoIncrementBy, generateAutoIncrementStartWith, generateDatabaseFunctionValue, generatePrimaryKeyName, get, getAutoCommitMode, getAutoIncrementByClause, getAutoIncrementClause, getAutoIncrementClause, getAutoIncrementClause, getAutoIncrementClosing, getAutoIncrementOpening, getAutoIncrementStartWithClause, getConcatSql, getConnection, getConnectionSchemaNameCallStatement, getContainingObjects, getCurrentDateTimeFunction, getDatabaseChangeLogLockTableName, getDatabaseChangeLogTableName, getDatabaseMajorVersion, getDatabaseMinorVersion, getDatabaseProductName, getDatabaseProductVersion, getDataTypeMaxParameters, getDateFunctions, getDateLiteral, getDateLiteral, getDateLiteral, getDateTimeLiteral, getDefaultDatabaseProductName, getDefaultFractionalDigitsForTimestamp, getDefaultScaleForNativeDataType, getDefaultSchema, getFetchSize, getJdbcCatalogName, getJdbcCatalogName, getJdbcSchemaName, getJdbcSchemaName, getLineComment, getLiquibaseCatalogName, getLiquibaseSchemaName, getLiquibaseTablespaceName, getMaxFractionalDigitsForTimestamp, getName, getObjectQuotingStrategy, getOutputDefaultCatalog, getOutputDefaultSchema, getQuotingEndCharacter, getQuotingEndReplacement, getQuotingStartCharacter, getRanChangeSet, getRanChangeSetList, getRanDate, getRunStatus, getSchemaAndCatalogCase, getSchemaFromJdbcInfo, getSystemSchema, getSystemTables, getSystemViews, getTimeLiteral, getViewDefinition, hashCode, isAutoCommit, isCurrentTimeFunction, isDateOnly, isDateTime, isDefaultCatalog, isDefaultSchema, isFunction, isLiquibaseObject, isReservedWord, isSystemObject, isSystemView, isTimeOnly, isTimestamp, jdbcCallsCatalogsSchemas, markChangeSetExecStatus, mustQuoteObjectName, parseDate, quoteObject, removeRanStatus, requiresExplicitNullForColumns, resetInternalState, rollback, saveRollbackStatement, saveStatements, set, setAutoCommit, setCanCacheLiquibaseTableInfo, setCaseSensitive, setCurrentDateTimeFunction, setDatabaseChangeLogLockTableName, setDatabaseChangeLogTableName, setDefaultCatalogName, setDefaultSchemaName, setLiquibaseCatalogName, setLiquibaseSchemaName, setLiquibaseTablespaceName, setObjectQuotingStrategy, setOutputDefaultCatalog, setOutputDefaultSchema, startsWithNumeric, supportsAutoIncrement, supportsBatchUpdates, supportsCatalogInObjectName, supportsDDLInTransaction, supportsDropTableCascadeConstraints, supportsForeignKeyDisable, supportsNotNullConstraintNames, supportsPrimaryKeyNames, supportsRestrictForeignKeys, supportsSequences, tag, toString, unescapeDataTypeName, unescapeDataTypeString, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface liquibase.database.Database

    getDisplayName, getShortName, isCorrectDatabaseImplementation
  • Field Details

    • dialect

      protected org.hibernate.dialect.Dialect dialect
    • DEFAULT_SCHEMA

      public static final String DEFAULT_SCHEMA
      See Also:
  • Constructor Details

    • HibernateDatabase

      public HibernateDatabase()
  • Method Details

    • requiresPassword

      public boolean requiresPassword()
      Specified by:
      requiresPassword in interface liquibase.database.Database
      Overrides:
      requiresPassword in class liquibase.database.AbstractJdbcDatabase
    • requiresUsername

      public boolean requiresUsername()
      Specified by:
      requiresUsername in interface liquibase.database.Database
      Overrides:
      requiresUsername in class liquibase.database.AbstractJdbcDatabase
    • getDefaultDriver

      public String getDefaultDriver(String url)
    • getPriority

      public int getPriority()
    • setConnection

      public void setConnection(liquibase.database.DatabaseConnection conn)
      Specified by:
      setConnection in interface liquibase.database.Database
      Overrides:
      setConnection in class liquibase.database.AbstractJdbcDatabase
    • findDialectName

      protected String findDialectName()
      Called by createMetadataSources() to determine the correct dialect name based on url parameters, configuration files, etc.
    • getDialect

      public org.hibernate.dialect.Dialect getDialect()
      Returns the dialect determined during database initialization.
    • getMetadata

      public org.hibernate.boot.Metadata getMetadata() throws liquibase.exception.DatabaseException
      Return the hibernate Metadata used by this database.
      Throws:
      liquibase.exception.DatabaseException
    • getHibernateConnection

      protected HibernateConnection getHibernateConnection()
      Convenience method to return the underlying HibernateConnection in the JdbcConnection returned by AbstractJdbcDatabase.getConnection()
    • buildMetadata

      protected final org.hibernate.boot.Metadata buildMetadata() throws liquibase.exception.DatabaseException
      Called by setConnection(DatabaseConnection) to create the Metadata stored in this database. If the URL path is configured for a CustomMetadataFactory, create the metadata from that class. Otherwise, it delegates to buildMetadataFromPath()
      Throws:
      liquibase.exception.DatabaseException
    • buildMetadataFromPath

      protected org.hibernate.boot.Metadata buildMetadataFromPath() throws liquibase.exception.DatabaseException
      Called by buildMetadata() when a CustomMetadataFactory is not configured. Default implementation passes the results of createMetadataSources() to configureSources(MetadataSources) and then calls configureMetadataBuilder(MetadataBuilder) but this method can be overridden with any provider-specific implementations needed.
      Throws:
      liquibase.exception.DatabaseException
    • createMetadataSources

      protected org.hibernate.boot.MetadataSources createMetadataSources() throws liquibase.exception.DatabaseException
      Creates the base MetadataSources to use for this database. Normally, the result of this method is passed through configureSources(MetadataSources).
      Throws:
      liquibase.exception.DatabaseException
    • configureSources

      protected abstract void configureSources(org.hibernate.boot.MetadataSources sources) throws liquibase.exception.DatabaseException
      Adds any implementation-specific sources to the given MetadataSources
      Throws:
      liquibase.exception.DatabaseException
    • configurePhysicalNamingStrategy

      protected void configurePhysicalNamingStrategy(String physicalNamingStrategy, org.hibernate.boot.MetadataBuilder builder) throws liquibase.exception.DatabaseException
      Throws:
      liquibase.exception.DatabaseException
    • configureImplicitNamingStrategy

      protected void configureImplicitNamingStrategy(String implicitNamingStrategy, org.hibernate.boot.MetadataBuilder builder) throws liquibase.exception.DatabaseException
      Throws:
      liquibase.exception.DatabaseException
    • afterSetup

      protected void afterSetup()
      Perform any post-configuration setting logic.
    • configureMetadataBuilder

      protected void configureMetadataBuilder(org.hibernate.boot.MetadataBuilder metadataBuilder) throws liquibase.exception.DatabaseException
      Called by buildMetadataFromPath() to do final configuration on the MetadataBuilder before MetadataBuilder.build() is called.
      Throws:
      liquibase.exception.DatabaseException
    • getProperty

      public String getProperty(String name)
      Returns the value of the given property. Should return the value given as a connection URL first, then fall back to configuration-specific values.
    • createsIndexesForForeignKeys

      public boolean createsIndexesForForeignKeys()
      Specified by:
      createsIndexesForForeignKeys in interface liquibase.database.Database
      Overrides:
      createsIndexesForForeignKeys in class liquibase.database.AbstractJdbcDatabase
    • getDefaultPort

      public Integer getDefaultPort()
    • supportsInitiallyDeferrableColumns

      public boolean supportsInitiallyDeferrableColumns()
    • supportsTablespaces

      public boolean supportsTablespaces()
    • getConnectionCatalogName

      protected String getConnectionCatalogName() throws liquibase.exception.DatabaseException
      Overrides:
      getConnectionCatalogName in class liquibase.database.AbstractJdbcDatabase
      Throws:
      liquibase.exception.DatabaseException
    • getConnectionSchemaName

      protected String getConnectionSchemaName()
      Overrides:
      getConnectionSchemaName in class liquibase.database.AbstractJdbcDatabase
    • getDefaultSchemaName

      public String getDefaultSchemaName()
      Specified by:
      getDefaultSchemaName in interface liquibase.database.Database
      Overrides:
      getDefaultSchemaName in class liquibase.database.AbstractJdbcDatabase
    • getDefaultCatalogName

      public String getDefaultCatalogName()
      Specified by:
      getDefaultCatalogName in interface liquibase.database.Database
      Overrides:
      getDefaultCatalogName in class liquibase.database.AbstractJdbcDatabase
    • isSafeToRunUpdate

      public boolean isSafeToRunUpdate() throws liquibase.exception.DatabaseException
      Specified by:
      isSafeToRunUpdate in interface liquibase.database.Database
      Overrides:
      isSafeToRunUpdate in class liquibase.database.AbstractJdbcDatabase
      Throws:
      liquibase.exception.DatabaseException
    • isCaseSensitive

      public boolean isCaseSensitive()
      Specified by:
      isCaseSensitive in interface liquibase.database.Database
      Overrides:
      isCaseSensitive in class liquibase.database.AbstractJdbcDatabase
    • supportsSchemas

      public boolean supportsSchemas()
      Specified by:
      supportsSchemas in interface liquibase.database.Database
      Overrides:
      supportsSchemas in class liquibase.database.AbstractJdbcDatabase
    • supportsCatalogs

      public boolean supportsCatalogs()
      Specified by:
      supportsCatalogs in interface liquibase.database.Database
      Overrides:
      supportsCatalogs in class liquibase.database.AbstractJdbcDatabase