CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-jooq--jooq-meta

Database metadata abstraction library for jOOQ's code generation system providing unified access to schema information across multiple database vendors

Pending
Overview
Eval results
Files

table-analysis.mddocs/

Table and Column Analysis

Detailed table structure analysis including columns, data types, nullability, defaults, identity columns, and special properties for comprehensive database schema understanding.

Capabilities

Table Structure Analysis

Core table analysis providing detailed information about table properties and characteristics.

/**
 * Gets all visible columns in the table
 * @returns List of column definitions (excludes hidden columns)
 */
List<ColumnDefinition> getColumns();

/**
 * Gets all columns including hidden system columns
 * @returns List of all column definitions including hidden ones
 */
List<ColumnDefinition> getColumnsIncludingHidden();

/**
 * Gets a specific column by name
 * @param name - Column name to lookup
 * @returns Column definition or null if not found
 */
ColumnDefinition getColumn(String name);

/**
 * Gets a specific column with case sensitivity control
 * @param name - Column name to lookup
 * @param ignoreCase - Whether to ignore case in name matching
 * @returns Column definition or null if not found
 */
ColumnDefinition getColumn(String name, boolean ignoreCase);

/**
 * Gets a specific column by jOOQ Name
 * @param name - jOOQ Name object for the column
 * @returns Column definition or null if not found
 */
ColumnDefinition getColumn(Name name);

/**
 * Gets a specific column by jOOQ Name with case sensitivity control
 * @param name - jOOQ Name object for the column
 * @param ignoreCase - Whether to ignore case in name matching
 * @returns Column definition or null if not found
 */
ColumnDefinition getColumn(Name name, boolean ignoreCase);

Usage Examples:

import org.jooq.meta.TableDefinition;
import org.jooq.meta.ColumnDefinition;
import org.jooq.Name;
import org.jooq.impl.DSL;

// Get all columns
List<ColumnDefinition> columns = table.getColumns();
for (ColumnDefinition column : columns) {
    System.out.println("Column: " + column.getName());
    System.out.println("  Type: " + column.getType().getType());
    System.out.println("  Nullable: " + column.getType().isNullable());
    System.out.println("  Position: " + column.getPosition());
}

// Get specific column
ColumnDefinition idColumn = table.getColumn("id");
if (idColumn != null && idColumn.isIdentity()) {
    System.out.println("Found identity column: " + idColumn.getName());
}

// Case-insensitive lookup
ColumnDefinition column = table.getColumn("Email", true);

// Using jOOQ Name
Name columnName = DSL.name("created_at");
ColumnDefinition createdAt = table.getColumn(columnName);

// Include hidden columns
List<ColumnDefinition> allColumns = table.getColumnsIncludingHidden();
System.out.println("Total columns (including hidden): " + allColumns.size());

Table Type Identification

Methods to identify different types of tables and table-like objects.

/**
 * Checks if this table is a view
 * @returns true if the table is a view
 */
boolean isView();

/**
 * Checks if this table is a materialized view
 * @returns true if the table is a materialized view
 */
boolean isMaterializedView();

/**
 * Checks if this table is a table-valued function
 * @returns true if the table represents a table-valued function
 */
boolean isTableValuedFunction();

/**
 * Checks if this table is temporary
 * @returns true if the table is temporary
 */
boolean isTemporary();

/**
 * Checks if this table is synthetic (artificially generated)
 * @returns true if the table is synthetic
 */
boolean isSynthetic();

Usage Examples:

import org.jooq.meta.TableDefinition;

// Identify table types
for (TableDefinition table : tables) {
    System.out.print("Table: " + table.getName() + " - ");
    
    if (table.isView()) {
        System.out.println("VIEW");
    } else if (table.isMaterializedView()) {
        System.out.println("MATERIALIZED VIEW");
    } else if (table.isTableValuedFunction()) {
        System.out.println("TABLE-VALUED FUNCTION");
    } else if (table.isTemporary()) {
        System.out.println("TEMPORARY TABLE");
    } else {
        System.out.println("TABLE");
    }
}

Column Data Type Analysis

Comprehensive column data type analysis including type information, precision, scale, and special properties.

/**
 * Gets the column's data type definition
 * @returns DataTypeDefinition with complete type information
 */
DataTypeDefinition getType();

/**
 * Gets the column position within the table
 * @returns Zero-based position of the column
 */
int getPosition();

/**
 * Checks if the column is an identity/auto-increment column
 * @returns true if the column is an identity column
 */
boolean isIdentity();

/**
 * Checks if the column can contain null values
 * @returns true if the column is nullable
 */
boolean isNullable();

/**
 * Checks if the column is hidden (system column)
 * @returns true if the column is hidden
 */
boolean isHidden();

/**
 * Checks if the column is readonly
 * @returns true if the column is readonly
 */
boolean isReadonly();

/**
 * Gets the column's default value expression
 * @returns Default value string or null if no default
 */
String getDefaultValue();

Usage Examples:

import org.jooq.meta.ColumnDefinition;
import org.jooq.meta.DataTypeDefinition;

// Analyze column properties
ColumnDefinition column = table.getColumn("email");
if (column != null) {
    DataTypeDefinition type = column.getType();
    
    System.out.println("Column: " + column.getName());
    System.out.println("  Data Type: " + type.getType());
    System.out.println("  Java Type: " + type.getJavaType());
    System.out.println("  Length: " + type.getLength());
    System.out.println("  Precision: " + type.getPrecision());
    System.out.println("  Scale: " + type.getScale());
    System.out.println("  Nullable: " + type.isNullable());
    System.out.println("  Default: " + column.getDefaultValue());
    System.out.println("  Position: " + column.getPosition());
    System.out.println("  Identity: " + column.isIdentity());
    System.out.println("  Hidden: " + column.isHidden());
    System.out.println("  Readonly: " + column.isReadonly());
}

// Find identity columns
List<ColumnDefinition> identityColumns = table.getColumns().stream()
    .filter(ColumnDefinition::isIdentity)
    .collect(Collectors.toList());

// Find nullable columns
List<ColumnDefinition> nullableColumns = table.getColumns().stream()
    .filter(col -> col.getType().isNullable())
    .collect(Collectors.toList());

Data Type Details

Detailed analysis of database data types and their properties.

/**
 * Gets database type name
 * @returns Native database type name
 */
String getType();

/**
 * Gets corresponding Java type name
 * @returns Java type name for code generation
 */
String getJavaType();

/**
 * Gets type length for character/binary types
 * @returns Type length or 0 if not applicable
 */
int getLength();

/**
 * Gets numeric precision
 * @returns Numeric precision or 0 if not applicable
 */
int getPrecision();

/**
 * Gets numeric scale
 * @returns Numeric scale or 0 if not applicable
 */
int getScale();

/**
 * Checks if column has default value
 * @returns true if column has a default value
 */
boolean isDefaulted();

/**
 * Checks if column is identity/auto-increment
 * @returns true if column is identity
 */ 
boolean isIdentity();

/**
 * Checks if column is readonly
 * @returns true if column is readonly
 */
boolean isReadonly();

Container and Parent Relationships

Methods for navigating from columns back to their containing tables and schemas.

/**
 * Gets the table containing this column
 * @returns TableDefinition that contains this column
 */
TableDefinition getContainer();

/**
 * Gets the schema containing this column's table
 * @returns SchemaDefinition containing the table
 */
SchemaDefinition getSchema();

/**
 * Gets the catalog containing this column's schema
 * @returns CatalogDefinition containing the schema
 */
CatalogDefinition getCatalog();

/**
 * Gets the database containing this column
 * @returns Database containing this column
 */
Database getDatabase();

Types

interface TableDefinition extends Definition {
    List<ColumnDefinition> getColumns();
    List<ColumnDefinition> getColumnsIncludingHidden();
    ColumnDefinition getColumn(String name);
    ColumnDefinition getColumn(String name, boolean ignoreCase);
    ColumnDefinition getColumn(Name name);
    ColumnDefinition getColumn(Name name, boolean ignoreCase);
    boolean isView();
    boolean isMaterializedView();
    boolean isTableValuedFunction();
    boolean isTemporary();
}

interface ColumnDefinition extends TypedElementDefinition<TableDefinition>, PositionedDefinition {
    TableDefinition getContainer();
    DataTypeDefinition getType();
    boolean isIdentity();
    boolean isNullable();
    boolean isHidden();
    boolean isReadonly();
    String getDefaultValue();
    int getPosition();
}

interface DataTypeDefinition {
    String getType();
    String getJavaType();
    int getLength();
    int getPrecision();
    int getScale();
    boolean isNullable();
    boolean isDefaulted();
    boolean isIdentity();
    boolean isReadonly();
}

interface TypedElementDefinition<T extends Definition> extends Definition {
    T getContainer();
    DataTypeDefinition getType();
}

interface PositionedDefinition extends Definition {
    int getPosition();
}

Usage Examples:

import org.jooq.meta.TableDefinition;
import org.jooq.meta.ColumnDefinition;
import org.jooq.meta.DataTypeDefinition;

// Complete table analysis
TableDefinition table = database.getTable(schema, "products");

System.out.println("Table: " + table.getName());
System.out.println("Type: " + (table.isView() ? "VIEW" : "TABLE"));
System.out.println("Columns: " + table.getColumns().size());

// Analyze each column
for (ColumnDefinition column : table.getColumns()) {
    DataTypeDefinition type = column.getType();
    
    System.out.println("\nColumn: " + column.getName());
    System.out.println("  Position: " + column.getPosition());
    System.out.println("  Type: " + type.getType());
    System.out.println("  Java Type: " + type.getJavaType());
    
    if (type.getLength() > 0) {
        System.out.println("  Length: " + type.getLength());
    }
    if (type.getPrecision() > 0) {
        System.out.println("  Precision: " + type.getPrecision());
        System.out.println("  Scale: " + type.getScale());
    }
    
    System.out.println("  Nullable: " + type.isNullable());
    System.out.println("  Identity: " + column.isIdentity());
    
    if (column.getDefaultValue() != null) {
        System.out.println("  Default: " + column.getDefaultValue());
    }
    
    // Navigate back to container
    System.out.println("  Table: " + column.getContainer().getName());
    System.out.println("  Schema: " + column.getSchema().getName());
}

Install with Tessl CLI

npx tessl i tessl/maven-org-jooq--jooq-meta

docs

advanced-objects.md

configuration.md

constraints-relationships.md

database-implementations.md

database-management.md

index.md

schema-discovery.md

table-analysis.md

tile.json