前人未踏の領域へ Androidアプリ開発編

Androidアプリ開発に関する調査メモ置き場。古い記事にはアプリ以外も含まれます。

DBの型をどうマッピングしているか

DBFluteのGeneratorを参考にAndroidSQLiteアクセス用のコードジェネレータを作ろうと思い調査。どうやら
org.seasar.dbflute.logic.jdbc.mapping.DfJdbcTypeMapperのgetColumnJdbcTypeで判断しているらしい。

    /**
     * Get the JDBC type of the column. <br /> 
     * The priority of mapping is as follows:
     * <pre>
     * 1. The specified type mapping by DB type name (typeMappingMap.dfprop)
     * 2. The fixed type mapping (PostgreSQL's OID and Oracle's Date and so on...)
     * 3. The standard type mapping by JDBC type if the type is not 'OTHER' (typeMappingMap.dfprop)
     * 4. The auto type mapping by DB type name
     * 5. String finally
     * </pre>
     * @param jdbcDefType The definition type of JDBC.
     * @param dbTypeName The name of DB data type. (NullAllowed: If null, the mapping using this is invalid)
     * @return The JDBC type of the column. (NotNull)
     */
    public String getColumnJdbcType(int jdbcDefType, String dbTypeName) {
        final String jdbcType = doGetColumnJdbcType(jdbcDefType, dbTypeName);
        if (jdbcType == null) {
            // * * * * * *
            // Priority 5
            // * * * * * *
            return getVarcharJdbcType();
        }
        return jdbcType;
    }

SQLiteのTEXT型はPriority 5に該当し、JDBCのVARCHARとして扱われJavaではStringとなる模様。

TorqueDataModelTask.javaをカスタマイズして自作のTemplateを使うようにすれば良さそうな雰囲気。