Package org.datanucleus.store.rdbms.schema

Examples of org.datanucleus.store.rdbms.schema.RDBMSColumnInfo


        // Validate the column(s)
        HashMap unvalidated = new HashMap(columnsByName);
        Iterator i = storeMgr.getColumnInfoForTable(this, conn).iterator();
        while (i.hasNext())
        {
            RDBMSColumnInfo ci = (RDBMSColumnInfo)i.next();
            DatastoreIdentifier colName = storeMgr.getIdentifierFactory().newIdentifier(IdentifierType.COLUMN, ci.getColumnName());
            Column col = (Column)unvalidated.get(colName);
            if (col == null)
            {
                if (!hasColumnName(colName))
                {
View Full Code Here


        HashMap unvalidated = new HashMap(columnsByName);
        List tableColInfo = storeMgr.getColumnInfoForTable(this, conn);
        Iterator i = tableColInfo.iterator();
        while (i.hasNext())
        {
            RDBMSColumnInfo ci = (RDBMSColumnInfo) i.next();

            // Create an identifier to use for the real column - use "CUSTOM" because we dont want truncation
            DatastoreIdentifier colName = storeMgr.getIdentifierFactory().newDatastoreFieldIdentifier(ci.getColumnName(),
                this.storeMgr.getNucleusContext().getTypeManager().isDefaultEmbeddedType(String.class), FieldRole.ROLE_CUSTOM);
            Column col = (Column) unvalidated.get(colName);
            if (col != null)
            {
                if (validateColumnStructure)
View Full Code Here

        while (i.hasNext())
        {
            Column col = i.next();
            if (col.isPrimaryKey())
            {
                RDBMSColumnInfo ci = storeMgr.getColumnInfoForColumnName(this, conn, col.getIdentifier());
                if (ci != null)
                {
                    col.initializeColumnInfoFromDatastore(ci);
                }
            }
View Full Code Here

    {
        HashMap columns = new HashMap(columnsByName);
        Iterator i = storeMgr.getColumnInfoForTable(this, conn).iterator();
        while (i.hasNext())
        {
            RDBMSColumnInfo ci = (RDBMSColumnInfo) i.next();
            DatastoreIdentifier colName = storeMgr.getIdentifierFactory().newIdentifier(IdentifierType.COLUMN, ci.getColumnName());
            Column col = (Column) columns.get(colName);
            if (col != null)
            {
                col.initializeColumnInfoFromDatastore(ci);
            }
View Full Code Here

     * @param rs ResultSet from DatabaseMetaData.getColumns()
     * @return column info
     */
    public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
    {
        RDBMSColumnInfo info = super.newRDBMSColumnInfo(rs);

        short dataType = info.getDataType();
        String typeName = info.getTypeName();

        //This is a fix to an issue in the MySQL JDBC driver 3.1.13
        //For columns of type BLOB, the driver returns -4 but should return 2004
        if (dataType == Types.LONGVARBINARY && typeName.equalsIgnoreCase("mediumblob"))
        {
            //change it to BLOB, since it is an BLOB
            info.setDataType((short)Types.BLOB);
        }
        //This is a fix to an issue in the MySQL JDBC driver 3.1.13
        //For columns of type CLOB, the driver returns -1 but should return 2005
        if (dataType == Types.LONGVARCHAR && typeName.equalsIgnoreCase("mediumtext"))
        {
            //change it to CLOB, since it is an CLOB
            info.setDataType((short)Types.CLOB);
        }

        return info;
    }
View Full Code Here

     * @param rs ResultSet from DatabaseMetaData.getColumns()
     * @return column info
     */
    public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
    {
        RDBMSColumnInfo info = new RDBMSColumnInfo(rs);

        String typeName = info.getTypeName();
        if (typeName.equalsIgnoreCase("text"))
        {
            // Equate "text" to Types.LONGVARCHAR
            info.setDataType((short)Types.LONGVARCHAR);
        }
        else if (typeName.equalsIgnoreCase("bytea"))
        {
            // Equate "bytea" to Types.LONGVARBINARY
            info.setDataType((short)Types.LONGVARBINARY);
        }

        /*
         * The PostgreSQL drivers sometimes produce some truly funky metadata.
         * I saw these next two occur during unit testing when
         * decimal_widget.big_decimal_field reported a columnSize of 65535 and
         * a decimalDigits of 65534, instead of the correct answers of 18 and 2.
         *
         * A -1 for either of these will cause their validation to be bypassed,
         * which is a shame but it's all we can do.  No one should be surprised
         * if we end up needing more of these.
         */
        int columnSize = info.getColumnSize();
        if (columnSize > PostgresqlTypeInfo.MAX_PRECISION)
        {
            info.setColumnSize(-1);
        }

        int decimalDigits = info.getDecimalDigits();
        if (decimalDigits > PostgresqlTypeInfo.MAX_PRECISION)
        {
            info.setDecimalDigits(-1);
        }

        return info;
    }
View Full Code Here

     * @param rs ResultSet from DatabaseMetaData.getColumns()
     * @return column info
     */
    public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
    {
        RDBMSColumnInfo info = new RDBMSColumnInfo(rs);
        String typeName = info.getTypeName();
        int dataType = -1;
        if (typeName == null)
        {
            dataType = Types.NULL;
        }
        else if (typeName.equals("ROWID"))
        {
            dataType = Types.INTEGER;
        }
        else if (typeName.equals("NUMBER") || typeName.equals("VARNUM"))
        {
            dataType = Types.NUMERIC;
        }
        else if (typeName.equals("VARCHAR2"))
        {
            dataType = Types.VARCHAR;
        }
        else if (typeName.equals("CHAR"))
        {
            dataType = Types.CHAR;
        }
        else if (typeName.equals("DATE"))
        {
            // should this be TIMESTAMP instead of DATE ??
            dataType = Types.DATE;
        }
        else if (typeName.equals("CLOB") || typeName.equals("NCLOB"))
        {
            dataType = Types.CLOB;
        }
        else if (typeName.equals("BLOB"))
        {
            dataType = Types.BLOB;
        }
        else if (typeName.equals("LONG"))
        {
            dataType = Types.LONGVARCHAR;
        }
        else if (typeName.equals("LONG RAW"))
        {
            dataType = Types.LONGVARBINARY;
        }
        else if (typeName.equals("RAW"))
        {
            dataType = Types.VARBINARY;
        }
        else if (typeName.startsWith("TIMESTAMP"))
        {
            dataType = Types.TIMESTAMP;
        }
        else if (typeName.equals("FLOAT"))
        {
            dataType = Types.FLOAT;
        }
        else
        {
            NucleusLogger.DATASTORE.warn(LOCALISER.msg("020191", typeName));
            dataType = Types.OTHER;
        }

        info.setDataType((short)dataType);

        return info;
    }
View Full Code Here

     * @throws SQLException
     */
    public RDBMSColumnInfo getColumnInfoForColumnName(Table table, Connection conn, DatastoreIdentifier column)
    throws SQLException
    {
        RDBMSColumnInfo colInfo = (RDBMSColumnInfo)schemaHandler.getSchemaData(
            conn, "column", new Object[] {table, column.getIdentifierName()});
        return colInfo;
    }
View Full Code Here

                        Iterator columnIter = tableInfo.getChildren().iterator();
                        while (columnIter.hasNext())
                        {
                            // Print out the column information
                            RDBMSColumnInfo colInfo = (RDBMSColumnInfo)columnIter.next();
                            ps.println(colInfo);
                        }
                    }
                }
            }
View Full Code Here

        return reservedKeywords.iterator();
    }

    public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
    {
        return new RDBMSColumnInfo(rs);
    }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.rdbms.schema.RDBMSColumnInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.