-
- All Superinterfaces:
Scope
public interface Meta extends Scope
A wrapping object forDatabaseMetaData
or for other sources of database meta information (e.g.InformationSchema
)This object can be obtained through
DSLContext.meta()
in order to provide convenient access to your database meta data. This abstraction has two purposes:- To increase API convenience, as no checked
SQLException
is thrown, only the uncheckedDataAccessException
- To increase API convenience, as the returned objects are always jOOQ
objects, not JDBC
ResultSet
objects with hard-to-remember API constraints
- Author:
- Lukas Eder
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Meta.Predicate<Q extends QueryPart>
A predicate to filter out query parts of a given type from meta data.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull Meta
apply(String migration)
Apply a migration to this meta to produce a newMeta
.@NotNull Meta
apply(Collection<? extends Query> migration)
Apply a migration to this meta to produce a newMeta
.@NotNull Meta
apply(Queries migration)
Apply a migration to this meta to produce a newMeta
.@NotNull Meta
apply(Query... migration)
Apply a migration to this meta to produce a newMeta
.@NotNull Queries
ddl()
Generate a creation script for the entire meta data.@NotNull Queries
ddl(DDLExportConfiguration configuration)
Generate a creation script for the entire meta data.@NotNull Meta
filterCatalogs(Meta.Predicate<? super Catalog> filter)
Create a wrapperMeta
instance filtering out some catalogs.@NotNull Meta
filterDomains(Meta.Predicate<? super Domain<?>> filter)
Create a wrapperMeta
instance filtering out some domains.@NotNull Meta
filterIndexes(Meta.Predicate<? super Index> filter)
Create a wrapperMeta
instance filtering out some indexes.@NotNull Meta
filterPrimaryKeys(Meta.Predicate<? super UniqueKey<?>> filter)
Create a wrapperMeta
instance filtering out some primary keys.@NotNull Meta
filterSchemas(Meta.Predicate<? super Schema> filter)
Create a wrapperMeta
instance filtering out some schemas.@NotNull Meta
filterSequences(Meta.Predicate<? super Sequence<?>> filter)
Create a wrapperMeta
instance filtering out some sequences.@NotNull Meta
filterTables(Meta.Predicate<? super Table<?>> filter)
Create a wrapperMeta
instance filtering out some tables.@NotNull Catalog
getCatalog(String name)
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.@NotNull Catalog
getCatalog(Name name)
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.@NotNull List<Catalog>
getCatalogs()
Get all catalog objects from the underlying meta data source.@NotNull List<Domain<?>>
getDomains()
Get all domain objects from the underlying meta data source.@NotNull List<Domain<?>>
getDomains(String name)
Get all domain objects by name from the underlying meta data source.@NotNull List<Domain<?>>
getDomains(Name name)
Get all domain objects by name from the underlying meta data source.@NotNull List<Index>
getIndexes()
Get all indexes from the underlying meta data sources.@NotNull List<UniqueKey<?>>
getPrimaryKeys()
Get all primary keys from the underlying meta data source.@NotNull List<Schema>
getSchemas()
Get all schema objects from the underlying meta data source.@NotNull List<Schema>
getSchemas(String name)
Get all schema objects by name from the underlying meta data source.@NotNull List<Schema>
getSchemas(Name name)
Get all schema objects by name from the underlying meta data source.@NotNull List<Sequence<?>>
getSequences()
Get all sequence objects from the underlying meta data source.@NotNull List<Sequence<?>>
getSequences(String name)
Get all sequence objects by name from the underlying meta data source.@NotNull List<Sequence<?>>
getSequences(Name name)
Get all sequence objects by name from the underlying meta data source.@NotNull List<Table<?>>
getTables()
Get all table objects from the underlying meta data source.@NotNull List<Table<?>>
getTables(String name)
Get all table objects by name from the underlying meta data source.@NotNull List<Table<?>>
getTables(Name name)
Get all table objects by name from the underlying meta data source.@NotNull InformationSchema
informationSchema()
Export to theInformationSchema
format.@NotNull Queries
migrateTo(Meta other)
Generate a migration script to get from this meta data to another one.@NotNull Queries
migrateTo(Meta other, MigrationConfiguration configuration)
Generate a migration script to get from this meta data to another one.@NotNull Meta
snapshot()
Eager-create an in-memory copy of thisMeta
instance without any connection to the original data source.
-
-
-
Method Detail
-
getCatalogs
@NotNull @Support @NotNull List<Catalog> getCatalogs() throws DataAccessException
Get all catalog objects from the underlying meta data source.For those databases that don't really support JDBC meta data catalogs, a single empty catalog (named
""
) will be returned. In other words, there is always at least one catalog in a database.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getCatalog
@NotNull @Support @NotNull Catalog getCatalog(String name) throws DataAccessException
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getCatalog
@NotNull @Support @NotNull Catalog getCatalog(Name name) throws DataAccessException
Get a catalog object by name from the underlying meta data source, ornull
if no such object exists.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@NotNull @Support @NotNull List<Schema> getSchemas() throws DataAccessException
Get all schema objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@NotNull @Support @NotNull List<Schema> getSchemas(String name) throws DataAccessException
Get all schema objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSchemas
@NotNull @Support @NotNull List<Schema> getSchemas(Name name) throws DataAccessException
Get all schema objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@NotNull @Support @NotNull List<Table<?>> getTables() throws DataAccessException
Get all table objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@NotNull @Support @NotNull List<Table<?>> getTables(String name) throws DataAccessException
Get all table objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getTables
@NotNull @Support @NotNull List<Table<?>> getTables(Name name) throws DataAccessException
Get all table objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getDomains
@NotNull @Support({AURORA_POSTGRES,H2,POSTGRES,SQLSERVER}) @NotNull List<Domain<?>> getDomains() throws DataAccessException
Get all domain objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getDomains
@NotNull @Support({AURORA_POSTGRES,H2,POSTGRES,SQLSERVER}) @NotNull List<Domain<?>> getDomains(String name) throws DataAccessException
Get all domain objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getDomains
@NotNull @Support({AURORA_POSTGRES,H2,POSTGRES,SQLSERVER}) @NotNull List<Domain<?>> getDomains(Name name) throws DataAccessException
Get all domain objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@NotNull @Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) @NotNull List<Sequence<?>> getSequences() throws DataAccessException
Get all sequence objects from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@NotNull @Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) @NotNull List<Sequence<?>> getSequences(String name) throws DataAccessException
Get all sequence objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getSequences
@NotNull @Support({AURORA_POSTGRES,COCKROACHDB,CUBRID,DB2,DERBY,FIREBIRD,H2,HANA,HSQLDB,INFORMIX,INGRES,ORACLE,POSTGRES,SQLSERVER2012,SYBASE}) @NotNull List<Sequence<?>> getSequences(Name name) throws DataAccessException
Get all sequence objects by name from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getPrimaryKeys
@NotNull @Support @NotNull List<UniqueKey<?>> getPrimaryKeys() throws DataAccessException
Get all primary keys from the underlying meta data source.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
getIndexes
@NotNull @Support @NotNull List<Index> getIndexes() throws DataAccessException
Get all indexes from the underlying meta data sources.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
filterCatalogs
@NotNull @NotNull Meta filterCatalogs(Meta.Predicate<? super Catalog> filter)
Create a wrapperMeta
instance filtering out some catalogs.
-
filterSchemas
@NotNull @NotNull Meta filterSchemas(Meta.Predicate<? super Schema> filter)
Create a wrapperMeta
instance filtering out some schemas.
-
filterTables
@NotNull @NotNull Meta filterTables(Meta.Predicate<? super Table<?>> filter)
Create a wrapperMeta
instance filtering out some tables.
-
filterDomains
@NotNull @NotNull Meta filterDomains(Meta.Predicate<? super Domain<?>> filter)
Create a wrapperMeta
instance filtering out some domains.
-
filterSequences
@NotNull @NotNull Meta filterSequences(Meta.Predicate<? super Sequence<?>> filter)
Create a wrapperMeta
instance filtering out some sequences.
-
filterPrimaryKeys
@NotNull @NotNull Meta filterPrimaryKeys(Meta.Predicate<? super UniqueKey<?>> filter)
Create a wrapperMeta
instance filtering out some primary keys.
-
filterIndexes
@NotNull @NotNull Meta filterIndexes(Meta.Predicate<? super Index> filter)
Create a wrapperMeta
instance filtering out some indexes.
-
snapshot
@NotNull @NotNull Meta snapshot() throws DataAccessException
Eager-create an in-memory copy of thisMeta
instance without any connection to the original data source.- Throws:
DataAccessException
-
ddl
@NotNull @NotNull Queries ddl() throws DataAccessException
Generate a creation script for the entire meta data.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
ddl
@NotNull @NotNull Queries ddl(DDLExportConfiguration configuration) throws DataAccessException
Generate a creation script for the entire meta data.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
@NotNull @NotNull Meta apply(String migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects- See Also:
Parser.parse(String)
-
apply
@NotNull @NotNull Meta apply(Query... migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
@NotNull @NotNull Meta apply(Collection<? extends Query> migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
apply
@NotNull @NotNull Meta apply(Queries migration) throws DataAccessException
Apply a migration to this meta to produce a newMeta
.- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
migrateTo
@NotNull @NotNull Queries migrateTo(Meta other) throws DataAccessException
Generate a migration script to get from this meta data to another one.See
migrateTo(Meta, MigrationConfiguration)
for more details.- Throws:
DataAccessException
- If something went wrong fetching the meta objects- See Also:
migrateTo(Meta, MigrationConfiguration)
-
migrateTo
@NotNull @NotNull Queries migrateTo(Meta other, MigrationConfiguration configuration) throws DataAccessException
Generate a migration script to get from this meta data to another one.To some extent, some database migrations can be generated automatically by comparing two versions of a schema. This is what
migrateTo()
does. It supports:- Schema additions / removals
- Table additions / removals
- Column additions / removals
- Column data type changes
- Constraint additions / removals
- Index additions / removals
- Sequence additions / removals
- Comment additions / removals
More complex, structural changes, such as moving some columns from one table to another, or turning a to-one relationship into a to-many relationship, as well as data migrations, can currently not be detected automatically.
- Throws:
DataAccessException
- If something went wrong fetching the meta objects
-
informationSchema
@NotNull @NotNull InformationSchema informationSchema() throws DataAccessException
Export to theInformationSchema
format.This allows for serialising schema meta information as XML using JAXB. See also
Constants.XSD_META
for details.- Throws:
DataAccessException
-
-