Class MTable

All Implemented Interfaces:
Serializable, Cloneable, Comparator<Object>, I_AD_Table, I_Persistent, Evaluatee, ImmutablePOSupport

public class MTable extends X_AD_Table implements ImmutablePOSupport
Persistent Table Model

Change log:

  • 2007-02-01 - teo_sarca - [ 1648850 ] MTable.getClass works incorrect for table "Fact_Acct"
  • 2007-08-30 - vpj-cd - [ 1784588 ] Use ModelPackage of EntityType to Find Model Class
Version:
$Id: MTable.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
Author:
Jorg Janke, Teo Sarca, teo.sarca@gmail.com
  • BF [ 3017117 ] MTable.getClass returns bad class https://sourceforge.net/p/adempiere/bugs/2433/
  • See Also:
    • Field Details

    • Constructor Details

      • MTable

        public MTable(Properties ctx, String AD_Table_UU, String trxName)
        UUID based Constructor
        Parameters:
        ctx - Context
        AD_Table_UU - UUID key
        trxName - Transaction
      • MTable

        public MTable(Properties ctx, int AD_Table_ID, String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        AD_Table_ID - id
        trxName - transaction
      • MTable

        public MTable(Properties ctx, ResultSet rs, String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - transaction
      • MTable

        public MTable(MTable copy)
        Copy constructor
        Parameters:
        copy -
      • MTable

        public MTable(Properties ctx, MTable copy)
        Copy constructor
        Parameters:
        ctx -
        copy -
      • MTable

        public MTable(Properties ctx, MTable copy, String trxName)
        Copy constructor
        Parameters:
        ctx -
        copy -
        trxName -
    • Method Details

      • get

        public static MTable get(int AD_Table_ID)
        Get MTable from Cache (immutable)
        Parameters:
        AD_Table_ID - id
        Returns:
        MTable
      • get

        public static MTable get(Properties ctx, int AD_Table_ID)
        Get MTable from Cache (immutable)
        Parameters:
        ctx - context
        AD_Table_ID - id
        Returns:
        MTable
      • get

        public static MTable get(Properties ctx, int AD_Table_ID, String trxName)
        Get MTable from Cache (immutable)
        Parameters:
        ctx - context
        AD_Table_ID - id
        trxName - transaction
        Returns:
        MTable
      • getCopy

        public static MTable getCopy(Properties ctx, int AD_Table_ID, String trxName)
        Get updateable copy of MTable from cache
        Parameters:
        ctx -
        AD_Table_ID -
        trxName -
        Returns:
        MTable
      • get

        public static MTable get(Properties ctx, String tableName)
        Get MTable from Cache
        Parameters:
        ctx - context
        tableName - case insensitive table name
        Returns:
        MTable
      • get

        public static MTable get(Properties ctx, String tableName, String trxName)
        Get MTable from Cache
        Parameters:
        ctx - context
        tableName - case insensitive table name
        trxName -
        Returns:
        MTable
      • getTableName

        public static String getTableName(Properties ctx, int AD_Table_ID)
        Get Table Name
        Parameters:
        ctx - context
        AD_Table_ID - table
        Returns:
        table name
      • getClass

        public static Class<?> getClass(String tableName)
        Get Java Model Class for Table
        Parameters:
        tableName - table name
        Returns:
        Java model class or null
      • getColumns

        public MColumn[] getColumns(boolean requery)
        Get Columns
        Parameters:
        requery - true to re-query from DB
        Returns:
        array of column
      • getColumn

        public MColumn getColumn(String columnName)
        Get Column via column name
        Parameters:
        columnName - (case insensitive)
        Returns:
        MColumn if found, null otherwise
      • getColumnIndex

        public int getColumnIndex(String ColumnName)
        Get Column Index via column name
        Parameters:
        ColumnName - column name (case insensitive)
        Returns:
        index of column with ColumnName or -1 if not found
      • columnExistsInDB

        public boolean columnExistsInDB(String ColumnName)
        Is column exists and is not virtual ?
        Parameters:
        ColumnName - column name (case insensitive)
        Returns:
        true if column exists and is not virtual
      • columnExistsInDictionary

        public boolean columnExistsInDictionary(String ColumnName)
        Column exists?
        Parameters:
        ColumnName - column name (case insensitive)
        Returns:
        true if column exists in dictionary
      • getColumnIndex

        public int getColumnIndex(int AD_Column_ID)
        Get Column Index
        Parameters:
        AD_Column_ID - column id
        Returns:
        index of column with AD_Column_ID or -1 if not found
      • isSingleKey

        public boolean isSingleKey()
        Table is with single primary key
        Returns:
        true if table has single primary key column
      • getKeyColumns

        public String[] getKeyColumns()
        Get Key Columns of Table
        Returns:
        array of key column name
      • isIDKeyTable

        public boolean isIDKeyTable()
        Returns:
        true if table has single key column and the key column name is the same as the table name plus _ID.
      • isUUIDKeyTable

        public boolean isUUIDKeyTable()
        Returns:
        true if table has single key column and the key column name ends with _UU.
      • hasUUIDKey

        public boolean hasUUIDKey()
        Returns:
        true if table has a UUID column (column name ends with _UU)
      • getIdentifierColumns

        public String[] getIdentifierColumns()
        Get Identifier Columns of Table (IsIdentifier=Y)
        Returns:
        array of identifier column name
      • getPO

        public PO getPO(int Record_ID, String trxName)
        Get PO Instance for this table
        Parameters:
        Record_ID - record id. 0 to create new record instance, > 0 to load existing record instance.
        trxName -
        Returns:
        PO for Record_ID or null
      • getPO

        public PO getPO(ResultSet rs, String trxName)
        Get PO Instance from result set
        Parameters:
        rs - result set
        trxName - transaction
        Returns:
        PO instance
      • getPOByUU

        public PO getPOByUU(String uuID, String trxName)
        Get PO Instance
        Parameters:
        uuID - UUID. Throw IllegalArgumentException if this is null or empty string.
        trxName - transaction
        Returns:
        PO for uuID
      • getPO

        public PO getPO(String whereClause, String trxName)
        Get PO Instance
        Parameters:
        whereClause - SQL where clause
        trxName - transaction
        Returns:
        PO for whereClause or null
      • getPO

        public PO getPO(String whereClause, Object[] params, String trxName)
        Get PO instance
        Parameters:
        whereClause - SQL where clause
        params - parameters for whereClause
        trxName -
        Returns:
        PO instance or null
      • beforeSave

        protected boolean beforeSave(boolean newRecord)
        Before Save
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - new
        Returns:
        true
      • afterSave

        protected boolean afterSave(boolean newRecord, boolean success)
        After Save
        Overrides:
        afterSave in class PO
        Parameters:
        newRecord - new
        success - success
        Returns:
        success
      • getSQLCreate

        public String getSQLCreate()
        Get Create table DDL
        Returns:
        create table DDL
      • getTable_ID

        public static int getTable_ID(String tableName)
        Get AD_Table_ID via table name
        Parameters:
        tableName -
        Returns:
        AD_Table_ID
      • getTable_ID

        public static int getTable_ID(String tableName, String trxName)
        Get AD_Table_ID via table name
        Parameters:
        tableName - String
        trxName -
        Returns:
        AD_Table_ID
      • createQuery

        public Query createQuery(String whereClause, String trxName)
        Create new query for whereClause
        Parameters:
        whereClause - SQL whereClause
        trxName -
        Returns:
        new Query instance
      • getViewComponent

        public MViewComponent[] getViewComponent(boolean reload)
        Get active view components
        Parameters:
        reload - true to reload from DB
        Returns:
        array of view component
      • toString

        public String toString()
        String Representation
        Overrides:
        toString in class X_AD_Table
        Returns:
        info
      • isZeroIDTable

        public static boolean isZeroIDTable(String tablename)
        Verify if the table has record with ID=0
        Returns:
        true if table has record with ID=0
      • markImmutable

        public MTable markImmutable()
        Description copied from interface: ImmutablePOSupport
        mark PO as immutable
        Specified by:
        markImmutable in interface ImmutablePOSupport
        Returns:
        PO
      • getWindowIDFromMenu

        public int getWindowIDFromMenu()
        Get first AD_Window that's using this table from AD_Menu.
        Returns:
        AD_Window_ID or -1 if not found
      • getUUIDFromZeroID

        public String getUUIDFromZeroID()
        Get the UUID of Zero ID record
        Returns:
        UUID or null
      • getPartitionKeyColumns

        public List<MColumn> getPartitionKeyColumns(boolean requery)
        Parameters:
        requery - true to reload from DB
        Returns:
        partition key columns
      • getPartitionKeyColumnNames

        public List<String> getPartitionKeyColumnNames()
        Returns:
        partition key column names
      • createTablePartition

        public X_AD_TablePartition createTablePartition(String name, String expression, String trxName, MColumn column)
        Create and save new X_AD_TablePartition record.
        Parameters:
        name -
        expression -
        trxName -
        column -
        Returns:
        new X_AD_TablePartition record
      • createTablePartition

        public X_AD_TablePartition createTablePartition(String name, String expression, String trxName, MColumn column, X_AD_TablePartition parentPartition)
        Create and save new X_AD_TablePartition record.
        Parameters:
        name -
        expression -
        trxName -
        column -
        parentPartition -
        Returns:
        new X_AD_TablePartition record
      • getTablePartitions

        public List<X_AD_TablePartition> getTablePartitions(boolean requery, String trxName)
        Parameters:
        requery - true to reload from DB
        trxName -
        Returns:
        X_AD_TablePartition records of this table
      • getTablePartitionNames

        public List<String> getTablePartitionNames(String trxName)
        Parameters:
        trxName -
        Returns:
        list of table partition name
      • getUUIDIndexName

        public static String getUUIDIndexName(String tableName)
        Get the Unique UU Index name
        Returns:
        indexName
      • hasCustomTree

        public boolean hasCustomTree()
        If the table has a custom tree defined
        Returns:
      • getPartitionName

        public static String getPartitionName(Properties ctx, String tableName, boolean primaryLevelOnly, String trxName)
        Get Partition Name of the table of the given level
        Parameters:
        tableName -
        primaryLevelOnly - - if true, ignore the sub-partition, if exists
        Returns:
        table partition name, or empty