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:
    Serialized Form
    • Constructor Detail

      • 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)
        Parameters:
        copy -
      • MTable

        public MTable​(Properties ctx,
                      MTable copy)
        Parameters:
        ctx -
        copy -
    • Method Detail

      • get

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

        public static MTable get​(Properties ctx,
                                 int AD_Table_ID)
        Get Table 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 Table 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 Table from Cache
        Parameters:
        ctx - context
        tableName - case insensitive table name
        Returns:
        Table
      • get

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

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

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

        public MColumn[] getColumns​(boolean requery)
        Get Columns
        Parameters:
        requery - requery
        Returns:
        array of columns
      • getColumn

        public MColumn getColumn​(String columnName)
        Get Column
        Parameters:
        columnName - (case insensitive)
        Returns:
        column if found
      • getColumnIndex

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

        public boolean columnExistsInDB​(String ColumnName)
        Column exists and is not virtual?
        Parameters:
        ColumnName - column name
        Returns:
        boolean - true indicating that the column exists in the table and is not virtual
      • columnExistsInDictionary

        public boolean columnExistsInDictionary​(String ColumnName)
        Column exists?
        Parameters:
        ColumnName - column name
        Returns:
        boolean - true indicating that the column exists in dictionary
      • getColumnIndex

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

        public boolean isSingleKey()
        Table has a single Key
        Returns:
        true if table has single key column
      • getKeyColumns

        public String[] getKeyColumns()
        Get Key Columns of Table
        Returns:
        key columns
      • getIdentifierColumns

        public String[] getIdentifierColumns()
        Get Identifier Columns of Table
        Returns:
        Identifier columns
      • getPO

        public PO getPO​(int Record_ID,
                        String trxName)
        Get PO Class Instance
        Parameters:
        Record_ID - record
        trxName -
        Returns:
        PO for Record or null
      • getPO

        public PO getPO​(ResultSet rs,
                        String trxName)
        Get PO Class Instance
        Parameters:
        rs - result set
        trxName - transaction
        Returns:
        PO for Record or null
      • getPOByUU

        public PO getPOByUU​(String uuID,
                            String trxName)
        Get PO Class Instance
        Parameters:
        uuID - UUID
        trxName - transaction
        Returns:
        PO for Record
      • getPO

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

        public PO getPO​(String whereClause,
                        Object[] params,
                        String trxName)
        Get PO class instance
        Parameters:
        whereClause -
        params -
        trxName -
        Returns:
      • 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 SQL Create
        Returns:
        create table DDL
      • getTable_ID

        public static int getTable_ID​(String tableName)
      • getTable_ID

        public static int getTable_ID​(String tableName,
                                      String trxName)
        Grant independence to GenerateModel from AD_Table_ID
        Parameters:
        tableName - String
        trxName -
        Returns:
        int retValue
      • createQuery

        public Query createQuery​(String whereClause,
                                 String trxName)
        Create query to retrieve one or more PO.
        Parameters:
        whereClause -
        trxName -
        Returns:
        Query
      • getViewComponent

        public MViewComponent[] getViewComponent​(boolean reload)
        Get view components
        Parameters:
        reload - reload data
        Returns:
        array of view component
      • isZeroIDTable

        public static boolean isZeroIDTable​(String tablename)
        Verify if the table contains ID=0
        Returns:
        true if table has zero ID