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

📄 abstractinsertaction.java

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

import org.speedframework.entity.ParamEntity;
import org.speedframework.exception.SpeedFrameworkException;
import org.speedframework.message.IMessage;
import org.speedframework.sql.IInsertSQL;
import org.speedframework.sql.ISelectSQL;
import org.speedframework.sql.ITableInfoSQL;
import java.util.List;
import java.util.Map;

/**
 * Class AbstractInsertAction
 * 
 * @author <a href="mailto:santafeng@gmail.com"> lizf </a>
 * @version $Revision:1.0.0, $Date: 2007-10-10 1:48:21 $
 */
public abstract class AbstractInsertAction extends AbstractAction implements
		IInsertAction {

	/*
	 * (非 Javadoc)
	 * 
	 * @see org.speedframework.action.IAction#doAction(org.speedframework.message.IMessage)
	 */
	public void doAction(IMessage message) {
		log.debug("Speed engine is Insert...");

		String isql;
		String idsql;
		ParamEntity entity = message.getParamEntity();
		Object pojo = entity.getEntity();
		IInsertSQL iOffer = factory.getInsertSQL();
		iOffer.setTableObject(pojo);
		ITableInfoSQL cOffer = this.factory.getTableInfoSQL();
		cOffer.setTableObject(pojo);
		ISelectSQL sOffer = this.factory.getSelectSQL();
		sOffer.setTableObject(pojo);
		String tableSchema;
		try {
			String[] columnCache = columnInfoCache.getColumnInfos(pojo);
			if (columnCache == null) {
				String SQL = cOffer.getSQL();

				this.columnInfoCache.putColumnInfo(pojo, this.executor.select(
						SQL, null));
			}
			if (entity.isOpenTableSchema()) {
				tableSchema = columnInfoCache.getTableschem(pojo);
				iOffer.setTableSchema(tableSchema);
				cOffer.setTableSchema(tableSchema);
				sOffer.setTableSchema(tableSchema);
			}

			isql = iOffer.getSQL();
			this.executor.setFactory(factory);

			List paramName = iOffer.getParam(isql);
			String[][] columnType = columnInfoCache.getColumnInfoType(pojo,
					paramName);

			executor.insert(isql, columnType, pojo);
			resultCache.removeCache(pojo, useCache);
			idsql = iOffer.getIdentitySQL();

			List rlist = executor.select(idsql, null);
			Map eny = (Map) rlist.get(0);
			String pk = eny.get("insertid").toString();
			String _sql = sOffer.getSQL(columnInfoCache.getAutoIncrement(pojo));
			Object[] inc_value = new Object[] { pk };
			List list = this.executor.select(_sql, inc_value, pojo.getClass());

			resultCache.removeCache(pojo, useCache);
			this.result = list.get(0);
			resultCache.putResults(_sql, inc_value, this.result, this.useCache);
		} catch (Exception e) {
			throw new SpeedFrameworkException("AbstractInsertAction error " + e);
		}
	}
}

⌨️ 快捷键说明

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