abstractloadaction.java

来自「羽量级数据持久层开发框架」· Java 代码 · 共 78 行

JAVA
78
字号
package org.speedframework.action;

import org.speedframework.entity.ParamEntity;
import org.speedframework.exception.SpeedFrameworkException;
import org.speedframework.message.IMessage;
import org.speedframework.sql.ISelectSQL;
import org.speedframework.sql.ITableInfoSQL;
import org.speedframework.utilities.StringUtils;

import java.io.Serializable;

import java.util.List;

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

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

		ParamEntity entity = message.getParamEntity();
		Class loadclass = entity.getLoadclass();
		Serializable id = entity.getId();		 
		try {
			Object tableObj = loadclass.newInstance();
			ISelectSQL sOffer = factory.getSelectSQL();
			sOffer.setTableObject(tableObj);
			String[] pkcolumnCache = columnInfoCache
					.getPrimaryKeyColumnInfos(tableObj);

			if (pkcolumnCache == null) {
				ITableInfoSQL tOffer=factory.getTableInfoSQL();
				tOffer.setTableObject(tableObj);
				String _sql = tOffer.getSQL();						
				List columnCache = this.executor.select(_sql, null);

				this.columnInfoCache.putColumnInfo(tableObj,
						columnCache);
				pkcolumnCache = columnInfoCache
						.getPrimaryKeyColumnInfos(tableObj);
			}
			if (entity.isOpenTableSchema()) {
				String tableSchema = columnInfoCache.getTableschem(tableObj);				
				sOffer.setTableSchema(tableSchema);
			}

			String sqlbyid = sOffer.getSelectSQLByID(loadclass, pkcolumnCache);
			String[] param = StringUtils.getSerializableID(id);

			this.result = this.resultCache.getResults(sqlbyid, param,
					this.useCache);

			if (this.result == null) {
				List list = this.executor.select(sqlbyid, param, loadclass);

				if (list.size() > 0) {
					this.result = list.get(0);
				}

				this.resultCache.putResults(sqlbyid, param, this.result,
						this.useCache);
			}
		} catch (Exception e) {
			throw new SpeedFrameworkException("AbstractLoadAction error " + e);
		}
	}
}

⌨️ 快捷键说明

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