/** * Gets a mapped statement by ID * * @param id - the ID * @return - the mapped statement */ public MappedStatement getMappedStatement(String id) { return delegate.getMappedStatement(id); }
/** * Gets a mapped statement by ID * * @param id - the ID * @return - the mapped statement */ public MappedStatement getMappedStatement(String id) { return delegate.getMappedStatement(id); }
public MappedStatement getMappedStatement(String id) { return delegate.getMappedStatement(id); }
public MappedStatement getMappedStatement(String id) { return delegate.getMappedStatement(id); }
public SqlMapQuery(QueryMethod queryMethod, SqlMapExecutorDelegate delegate, SqlMapClientTemplate sqlMapClientTemplate) { this.queryMethod = queryMethod; this.template = sqlMapClientTemplate; // iBatis에게 statement(query)의 유형(select, insert, update, delete) 얻기 MappedStatement statement = delegate.getMappedStatement(queryMethod.getNamedQueryName()); this.statementType = statement.getStatementType(); }
@Override public List<String> getWriteDatasetIds() { if(attributesNameCache != null && attributesNameCache.size() > 0) { return attributesNameCache.get(serviceName); } attributesNameCache.put(serviceName, new ArrayList<String>()); if(sqlMapper instanceof SqlMapClientImpl) { for(String request: getRequestsNameForInsert()) { for(ParameterMapping pm : ((SqlMapClientImpl)sqlMapper).getDelegate().getMappedStatement(request).getParameterMap().getParameterMappings()) { attributesNameCache.get(serviceName).add(pm.getPropertyName()); } } } else { LOGGER.error("Unable to handle an unknown SQLMap Client type : " + sqlMapper.getClass().getName()); } return attributesNameCache.get(serviceName); }
private void wireUpCacheModels() { // Wire Up Cache Models Iterator cacheNames = client.getDelegate().getCacheModelNames(); while (cacheNames.hasNext()) { String cacheName = (String) cacheNames.next(); CacheModel cacheModel = client.getDelegate().getCacheModel(cacheName); Iterator statementNames = cacheModel.getFlushTriggerStatementNames(); while (statementNames.hasNext()) { String statementName = (String) statementNames.next(); MappedStatement statement = client.getDelegate().getMappedStatement(statementName); if (statement != null) { statement.addExecuteListener(cacheModel); } else { throw new RuntimeException("Could not find statement named '" + statementName + "' for use as a flush trigger for the cache model named '" + cacheName + "'."); } } } }
private void wireUpCacheModels() { // Wire Up Cache Models Iterator cacheNames = client.getDelegate().getCacheModelNames(); while (cacheNames.hasNext()) { String cacheName = (String) cacheNames.next(); CacheModel cacheModel = client.getDelegate().getCacheModel(cacheName); Iterator statementNames = cacheModel.getFlushTriggerStatementNames(); while (statementNames.hasNext()) { String statementName = (String) statementNames.next(); MappedStatement statement = client.getDelegate().getMappedStatement(statementName); if (statement != null) { statement.addExecuteListener(cacheModel); } else { throw new RuntimeException("Could not find statement named '" + statementName + "' for use as a flush trigger for the cache model named '" + cacheName + "'."); } } } }
protected IndexEntity[] doGetIndexEntities() throws CompassGpsException { ExtendedSqlMapClient extSqlMapClient = (ExtendedSqlMapClient) sqlMapClient; IndexEntity[] entities = new IndexEntity[selectStatementsIds.length]; for (int i = 0; i < selectStatementsIds.length; i++) { String statementId = selectStatementsIds[i]; MappedStatement statement = extSqlMapClient.getDelegate().getMappedStatement(statementId); if (statement == null) { throw new IllegalArgumentException("Failed to find statement for [" + statementId + "]"); } Class resultClass = statement.getResultMap().getResultClass(); ResourceMapping resourceMapping = ((CompassGpsInterfaceDevice) getGps()).getMappingForEntityForIndex(resultClass); if (resourceMapping == null) { throw new IllegalArgumentException("Failed to find mapping for class [" + resultClass.getName() + "]"); } Object parameterObject = null; if (statementsParameterObjects != null) { parameterObject = statementsParameterObjects[i]; } entities[i] = new SqlMapIndexEntity(resultClass.getName(), resourceMapping.getSubIndexHash().getSubIndexes(), statementId, parameterObject); } return entities; }
/** * Execute a query with a row handler. * The row handler is called once per row in the query results. * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param rowHandler - the row handler * @throws SQLException - if the query fails */ public void queryWithRowHandler(SessionScope sessionScope, String id, Object paramObject, RowHandler rowHandler) throws SQLException { MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { ms.executeQueryWithRowHandler(statementScope, trans, paramObject, rowHandler); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } }
/** * Execute a query with a row handler. * The row handler is called once per row in the query results. * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param rowHandler - the row handler * @throws SQLException - if the query fails */ public void queryWithRowHandler(SessionScope sessionScope, String id, Object paramObject, RowHandler rowHandler) throws SQLException { MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { ms.executeQueryWithRowHandler(statementScope, trans, paramObject, rowHandler); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } }
/** * Execute an update statement * * @param sessionScope - the session scope * @param id - the statement ID * @param param - the parameter object * @return - the number of rows updated * @throws SQLException - if the update fails */ public int update(SessionScope sessionScope, String id, Object param) throws SQLException { int rows = 0; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { rows = ms.executeUpdate(statementScope, trans, param); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return rows; }
/** * Execute a query for a list * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param skip - the number of rows to skip * @param max - the maximum number of rows to return * @return - the data list * @throws SQLException - if the query fails */ public List queryForList(SessionScope sessionScope, String id, Object paramObject, int skip, int max) throws SQLException { List list = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { list = ms.executeQueryForList(statementScope, trans, paramObject, skip, max); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return list; }
/** * Execute a query for a list * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param skip - the number of rows to skip * @param max - the maximum number of rows to return * @return - the data list * @throws SQLException - if the query fails */ public List queryForList(SessionScope sessionScope, String id, Object paramObject, int skip, int max) throws SQLException { List list = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { list = ms.executeQueryForList(statementScope, trans, paramObject, skip, max); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return list; }
/** * Execute a select for a single object * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param resultObject - the result object (if not supplied or null, a new object will be created) * @return - the result of the query * @throws SQLException - if the query fails */ public Object queryForObject(SessionScope sessionScope, String id, Object paramObject, Object resultObject) throws SQLException { Object object = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { object = ms.executeQueryForObject(statementScope, trans, paramObject, resultObject); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return object; }
/** * Execute a select for a single object * * @param sessionScope - the session scope * @param id - the statement ID * @param paramObject - the parameter object * @param resultObject - the result object (if not supplied or null, a new object will be created) * @return - the result of the query * @throws SQLException - if the query fails */ public Object queryForObject(SessionScope sessionScope, String id, Object paramObject, Object resultObject) throws SQLException { Object object = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { object = ms.executeQueryForObject(statementScope, trans, paramObject, resultObject); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return object; }
/** * Execute an update statement * * @param sessionScope - the session scope * @param id - the statement ID * @param param - the parameter object * @return - the number of rows updated * @throws SQLException - if the update fails */ public int update(SessionScope sessionScope, String id, Object param) throws SQLException { int rows = 0; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null; try { trans = autoStartTransaction(sessionScope, autoStart, trans); StatementScope statementScope = beginStatementScope(sessionScope, ms); try { rows = ms.executeUpdate(statementScope, trans, param); } finally { endStatementScope(statementScope); } autoCommitTransaction(sessionScope, autoStart); } finally { autoEndTransaction(sessionScope, autoStart); } return rows; }
Object generatedKey = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null;
Object generatedKey = null; MappedStatement ms = getMappedStatement(id); Transaction trans = getTransaction(sessionScope); boolean autoStart = trans == null;