All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.quickdao.module.database.parent.flow.GetAndCacheStatementFlow Maven / Gradle / Ivy

There is a newer version: 5.3.1
Show newest version
package cn.schoolwow.quickdao.module.database.parent.flow;

import cn.schoolwow.quickdao.domain.QuickDAOConfig;
import cn.schoolwow.quickdao.module.database.parent.domain.GetStatementSupplier;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class GetAndCacheStatementFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        QuickDAOConfig quickDAOConfig = (QuickDAOConfig) flowContext.checkData("quickDAOConfig");
        String sqlCacheName = (String) flowContext.checkData("sqlCacheName");

        if(quickDAOConfig.databaseContext.statementCache.contains(sqlCacheName)){
            flowContext.putData("sql", quickDAOConfig.databaseContext.statementCache.get(sqlCacheName));
        }else{
            GetStatementSupplier getStatementSupplier = (GetStatementSupplier) flowContext.checkData("getStatementSupplier");
            String sql = getStatementSupplier.getStatement();
            quickDAOConfig.databaseContext.statementCache.put(sqlCacheName, sql);
            flowContext.putData("sql", sql);
        }
    }

    @Override
    public String name() {
        return "获取并缓存SQL语句";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy