⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postgresqlcolumninfocache.java

📁 羽量级数据持久层开发框架
💻 JAVA
字号:
package org.speedframework.cache.postgresql;

//~--- non-JDK imports --------------------------------------------------------

import org.speedframework.cache.AbstractColumnInfoCache;
import org.speedframework.entity.CacheColumnBean;
import org.speedframework.utilities.StringUtils;

//~--- JDK imports ------------------------------------------------------------

import java.sql.Array;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 *  类描述信息,描述类的主要职责和用处。
 *
 *
 * @version    $LastChangedRevision: 1945 $, 2007.09.29 at 02:14:28 CST
 * @author     <a href="mailto:falcon8848@gmail.com">piginzoo </a>
 */
public class PostgresqlColumnInfoCache extends AbstractColumnInfoCache
 {

    /**
     * 方法描述信息,
     * 描述方法是做什么的,
     * 如何调用,最好给出调用代码示例。
     *
     * @param table
     * @param columnInfo
     *
     * @throws Exception
     */
    public void putColumnInfo(Object table, List columnInfo) throws Exception {
        List     colunm    = null;
        String   tableName = StringUtils.getExcuteTableName(table.getClass());
        Iterator it        = columnInfo.iterator();

        if (it.hasNext()) {
            colunm = new ArrayList();
        }

        Array conkey = null;

        while (it.hasNext()) {
            Map    entity        = (Map) it.next();
            String columnName    = (String) entity.get("attname");
            String dataType      = (String) entity.get("typname");
            String autoincrement = (String) entity.get("adsrc");
            String attnum        = entity.get("attnum").toString();

            conkey = (Array) entity.get("conkey");

            int[]           ic  = (int[]) conkey.getArray();
            CacheColumnBean ccb = new CacheColumnBean();

            ccb.setColumnname(columnName.toLowerCase());
            ccb.setDatatype(dataType.toLowerCase());

            if (ic.length > 0) {
                for (int i = 0; i < ic.length; i++) {
                    if (Integer.toString(ic[i]).equals(attnum)) {
                        ccb.setPrimarykey(true);

                        break;
                    }
                }
            }

            if ((autoincrement != null) &&!autoincrement.toLowerCase().equals("")) {
                ccb.setAutoincrement(true);
            }

            colunm.add(ccb);
        }

        ca.save(tableName, colunm);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -