Java(140)
-
Mybatis where절 if문으로 처리
SELECT * FROM your_table AND column1 = #{param1} AND column2 = #{param2} AND column3 LIKE CONCAT('%', #{param3}, '%')
2025.01.19 -
Mybatis 쿼리 결과 출력하기
Interceptor 생성import lombok.extern.slf4j.Slf4j;import org.apache.ibatis.executor.parameter.ParameterHandler;import org.apache.ibatis.executor.statement.StatementHandler;import org.apache.ibatis.plugin.*;import org.apache.ibatis.mapping.BoundSql;import java.sql.Connection;import java.util.Properties;@Slf4j@Intercepts({ @Signature(type = StatementHandler.class, method = "prepare", args = {Conne..
2025.01.18 -
Java Map에서 key 찾기
Map searchForm = new HashMap();searchForm.put("name", "Alice");boolean result = searchForm.containsKey("name"); // true
2025.01.15 -
Java Map에서 동일한 패턴의 key, value 정보 가져오기
entrySet() 이용// Filter entries with keys starting with "DATA"Map filteredMap = searchForm.entrySet() .stream() .filter(entry -> entry.getKey().startsWith("DATA")) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));for문 이용// Extract keys into a list for iterationList keys = new ArrayList(searchForm.keySet());// Result map to store filtered entriesMap filteredM..
2025.01.15 -
Mybatis 반복문 처리
쿼리 쿼리 쿼리
2025.01.15 -
Mybatis ${} 사용시 SQL Injection 피하기
// Example: Validate column names and operatorsList validColumns = Arrays.asList("column1", "column2", "column3");List validOperators = Arrays.asList("=", "", "=", "like");for (Map condition : conditions) { String column = (String) condition.get("data"); String operator = (String) condition.get("compare"); if (!validColumns.contains(column)) { throw new IllegalArgumentException("..
2025.01.15