Skip to content

Commit

Permalink
#266 - where now added to sql template
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Feb 11, 2024
1 parent 94d0d00 commit a408e65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.mybatis.dynamic.sql.SqlCriterion;

import java.util.List;
import java.util.Map;

@Builder
@AllArgsConstructor
Expand Down Expand Up @@ -40,8 +41,8 @@ public class ReadContextV2 {
/* Attributes to replace the ones above */
DbTable root;
List<DbColumn> cols;


String rootWhere;
Map<String,Object> paramMap;

public void addWhereCondition(SqlCriterion whereCondition) {
this.whereCondition = whereCondition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ public void createQuery(ReadContextV2 readContextV2) {

log.info("**** Preparing to render ****");

Map data = new HashMap();
Map<String,Object> data = new HashMap<>();
data.put("columns", readContextV2.getCols());
data.put("rootTable", readContextV2.getRoot());
data.put("rootWhere", readContextV2.getRootWhere());
sqlRenderer.render("read", data);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void process(ReadContextV2 readContextV2) {

log.info("param map - {}", paramMap);

//readContextV2.addWhereCondition(condition);
readContextV2.setRootWhere(where);
readContextV2.setParamMap(paramMap);

}
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/resources/sql-templates/read.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SELECT
[# th:each="column : ${columns}"]
[(${column.name})]
[/]
[(${column.name})][/]
FROM
[(${rootTable.name})]

[# th:if="${rootWhere}"]WHERE
[(${rootWhere})]
[/]

0 comments on commit a408e65

Please sign in to comment.