mysqlcolumninfocache.java
来自「羽量级数据持久层开发框架」· Java 代码 · 共 58 行
JAVA
58 行
package org.speedframework.cache.mysql;
import org.speedframework.cache.AbstractColumnInfoCache;
import org.speedframework.entity.CacheColumnBean;
import org.speedframework.utilities.StringUtils;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Class MySQLColumnInfoCache
*
* @author <a href="mailto:santafeng@gmail.com"> lizf </a>
* @version $Revision:1.0.0, $Date: 2007-10-9 8:19:16 $
*/
public class MySQLColumnInfoCache extends AbstractColumnInfoCache {
/* (非 Javadoc)
* @see org.speedframework.cache.IColumnInfoCache#putColumnInfo(java.lang.Object, java.util.List)
*/
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();
}
while (it.hasNext()) {
Map entity = (Map) it.next();
String columnName = (String) entity.get("field");
String primaryKey = (String) entity.get("key");
String dataType = (String) entity.get("type");
String autoincrement = (String) entity.get("extra");
CacheColumnBean ccb = new CacheColumnBean();
ccb.setColumnname(columnName.toLowerCase());
ccb.setDatatype(dataType.toLowerCase());
if ((primaryKey != null) && primaryKey.toLowerCase().equals("pri")) {
ccb.setPrimarykey(true);
}
if ((autoincrement != null)
&& autoincrement.toLowerCase().equals("auto_increment")) {
ccb.setAutoincrement(true);
}
colunm.add(ccb);
}
ca.save(tableName, colunm);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?