Skip to content

Commit ded316b

Browse files
committed
게시물 본문 (content) 컬럼을 CLOB로 변경
에디터를 붙이기 전에 VARCHAR(2000)에서 CLOB로 변경해둔다. 특이한점은... VO의 content 필드가 맨 마지막으로 바뀌였다. CLOB로 바꾼 영향인지? 그런데 자동생성 VO, Mapper 부분은 블랙박스라 생각하고, 만들어지는대로 쓰는것이 좋을 것 같아, 억지로 순서를 맞추지는 말자! (가능한지도 모르겠지만.. 😅)
1 parent aa0f208 commit ded316b

9 files changed

Lines changed: 46 additions & 43 deletions

File tree

part-last/my-board-mds/docker/init-scripts/01_schema.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ CREATE SEQUENCE IF NOT EXISTS seq_board START WITH 1 INCREMENT BY 1 NOCACHE NOCY
1111
CREATE TABLE IF NOT EXISTS tbl_board
1212
(
1313
bno NUMBER(18),
14-
title VARCHAR2(200) NOT NULL,
15-
content VARCHAR2(2000) NOT NULL,
16-
writer VARCHAR2(50) NOT NULL,
14+
title VARCHAR2(200) NOT NULL,
15+
content CLOB NOT NULL,
16+
writer VARCHAR2(50) NOT NULL,
1717
regdate TIMESTAMP(6) DEFAULT SYSTIMESTAMP,
1818
updatedate TIMESTAMP(6) DEFAULT SYSTIMESTAMP,
1919
replycnt NUMBER(10) DEFAULT 0,

part-last/my-board-mds/generatorConfig.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151

5252
<!-- Oracle에서 bno 컬럼을 NUMBER(18)으로 설정 jdbcType은 따로 지정하지 않으면 NUMERIC으로 설정된다. -->
5353
<columnOverride column="bno" property="bno" javaType='java.lang.Long'/>
54+
<columnOverride column="content" property="content"
55+
jdbcType="CLOB"
56+
javaType='java.lang.String'/>
5457
<columnOverride column="regdate" property="regdate"
5558
javaType='java.time.LocalDateTime'/>
5659
<columnOverride column="updatedate" property="updateDate"

part-last/my-board-mds/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"type": "module",
55
"private": "true",
6-
"packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
6+
"packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8",
77
"scripts": {
88
"preinstall": "npx only-allow pnpm",
99
"format": "prettier --write \"./**/*.{html,css,js,json}\"",
@@ -16,4 +16,4 @@
1616
"prettier": "3.8.3",
1717
"vscode-java-setup-scripts": "github:fp024/vscode-java-setup-scripts#v0.1.0"
1818
}
19-
}
19+
}

part-last/my-board-mds/src/main/java/org/fp024/domain/generated/BoardVO.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ public class BoardVO {
1010
@Generated("org.mybatis.generator.api.MyBatisGenerator")
1111
private String title;
1212

13-
@Generated("org.mybatis.generator.api.MyBatisGenerator")
14-
private String content;
15-
1613
@Generated("org.mybatis.generator.api.MyBatisGenerator")
1714
private String writer;
1815

@@ -25,6 +22,9 @@ public class BoardVO {
2522
@Generated("org.mybatis.generator.api.MyBatisGenerator")
2623
private int replyCount;
2724

25+
@Generated("org.mybatis.generator.api.MyBatisGenerator")
26+
private String content;
27+
2828
@Generated("org.mybatis.generator.api.MyBatisGenerator")
2929
public Long getBno() {
3030
return bno;
@@ -45,16 +45,6 @@ public void setTitle(String title) {
4545
this.title = title == null ? null : title.trim();
4646
}
4747

48-
@Generated("org.mybatis.generator.api.MyBatisGenerator")
49-
public String getContent() {
50-
return content;
51-
}
52-
53-
@Generated("org.mybatis.generator.api.MyBatisGenerator")
54-
public void setContent(String content) {
55-
this.content = content == null ? null : content.trim();
56-
}
57-
5848
@Generated("org.mybatis.generator.api.MyBatisGenerator")
5949
public String getWriter() {
6050
return writer;
@@ -95,6 +85,16 @@ public void setReplyCount(int replyCount) {
9585
this.replyCount = replyCount;
9686
}
9787

88+
@Generated("org.mybatis.generator.api.MyBatisGenerator")
89+
public String getContent() {
90+
return content;
91+
}
92+
93+
@Generated("org.mybatis.generator.api.MyBatisGenerator")
94+
public void setContent(String content) {
95+
this.content = content == null ? null : content.trim();
96+
}
97+
9898
@Override
9999
@Generated("org.mybatis.generator.api.MyBatisGenerator")
100100
public String toString() {
@@ -104,11 +104,11 @@ public String toString() {
104104
sb.append("Hash = ").append(hashCode());
105105
sb.append(", bno=").append(bno);
106106
sb.append(", title=").append(title);
107-
sb.append(", content=").append(content);
108107
sb.append(", writer=").append(writer);
109108
sb.append(", regdate=").append(regdate);
110109
sb.append(", updateDate=").append(updateDate);
111110
sb.append(", replyCount=").append(replyCount);
111+
sb.append(", content=").append(content);
112112
sb.append("]");
113113
return sb.toString();
114114
}

part-last/my-board-mds/src/main/java/org/fp024/mapper/generated/BoardMapper.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@Mapper
3434
public interface BoardMapper extends CommonCountMapper, CommonDeleteMapper, CommonUpdateMapper {
3535
@Generated("org.mybatis.generator.api.MyBatisGenerator")
36-
BasicColumn[] selectList = BasicColumn.columnList(bno, title, content, writer, regdate, updateDate, replyCount);
36+
BasicColumn[] selectList = BasicColumn.columnList(bno, title, writer, regdate, updateDate, replyCount, content);
3737

3838
@Generated("org.mybatis.generator.api.MyBatisGenerator")
3939
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
@@ -45,11 +45,11 @@ public interface BoardMapper extends CommonCountMapper, CommonDeleteMapper, Comm
4545
@Results(id="BoardVOResult", value = {
4646
@Result(column="BNO", property="bno", jdbcType=JdbcType.NUMERIC, id=true),
4747
@Result(column="TITLE", property="title", jdbcType=JdbcType.VARCHAR),
48-
@Result(column="CONTENT", property="content", jdbcType=JdbcType.VARCHAR),
4948
@Result(column="WRITER", property="writer", jdbcType=JdbcType.VARCHAR),
5049
@Result(column="REGDATE", property="regdate", jdbcType=JdbcType.TIMESTAMP),
5150
@Result(column="UPDATEDATE", property="updateDate", jdbcType=JdbcType.TIMESTAMP),
52-
@Result(column="REPLYCNT", property="replyCount", jdbcType=JdbcType.NUMERIC)
51+
@Result(column="REPLYCNT", property="replyCount", jdbcType=JdbcType.NUMERIC),
52+
@Result(column="CONTENT", property="content", jdbcType=JdbcType.CLOB)
5353
})
5454
List<BoardVO> selectMany(SelectStatementProvider selectStatement);
5555

@@ -80,11 +80,11 @@ default int insert(BoardVO row) {
8080
return MyBatis3Utils.insert(this::insert, row, boardVO, c ->
8181
c.map(bno).toProperty("bno")
8282
.map(title).toProperty("title")
83-
.map(content).toProperty("content")
8483
.map(writer).toProperty("writer")
8584
.map(regdate).toProperty("regdate")
8685
.map(updateDate).toProperty("updateDate")
8786
.map(replyCount).toProperty("replyCount")
87+
.map(content).toProperty("content")
8888
);
8989
}
9090

@@ -93,11 +93,11 @@ default int insertSelective(BoardVO row) {
9393
return MyBatis3Utils.insert(this::insert, row, boardVO, c ->
9494
c.map(bno).toProperty("bno")
9595
.map(title).toPropertyWhenPresent("title", row::getTitle)
96-
.map(content).toPropertyWhenPresent("content", row::getContent)
9796
.map(writer).toPropertyWhenPresent("writer", row::getWriter)
9897
.map(regdate).toPropertyWhenPresent("regdate", row::getRegdate)
9998
.map(updateDate).toPropertyWhenPresent("updateDate", row::getUpdateDate)
10099
.map(replyCount).toPropertyWhenPresent("replyCount", row::getReplyCount)
100+
.map(content).toPropertyWhenPresent("content", row::getContent)
101101
);
102102
}
103103

@@ -132,33 +132,33 @@ default int update(UpdateDSLCompleter completer) {
132132
static UpdateDSL<UpdateModel> updateAllColumns(BoardVO row, UpdateDSL<UpdateModel> dsl) {
133133
return dsl.set(bno).equalTo(row::getBno)
134134
.set(title).equalTo(row::getTitle)
135-
.set(content).equalTo(row::getContent)
136135
.set(writer).equalTo(row::getWriter)
137136
.set(regdate).equalTo(row::getRegdate)
138137
.set(updateDate).equalTo(row::getUpdateDate)
139-
.set(replyCount).equalTo(row::getReplyCount);
138+
.set(replyCount).equalTo(row::getReplyCount)
139+
.set(content).equalTo(row::getContent);
140140
}
141141

142142
@Generated("org.mybatis.generator.api.MyBatisGenerator")
143143
static UpdateDSL<UpdateModel> updateSelectiveColumns(BoardVO row, UpdateDSL<UpdateModel> dsl) {
144144
return dsl.set(bno).equalToWhenPresent(row::getBno)
145145
.set(title).equalToWhenPresent(row::getTitle)
146-
.set(content).equalToWhenPresent(row::getContent)
147146
.set(writer).equalToWhenPresent(row::getWriter)
148147
.set(regdate).equalToWhenPresent(row::getRegdate)
149148
.set(updateDate).equalToWhenPresent(row::getUpdateDate)
150-
.set(replyCount).equalToWhenPresent(row::getReplyCount);
149+
.set(replyCount).equalToWhenPresent(row::getReplyCount)
150+
.set(content).equalToWhenPresent(row::getContent);
151151
}
152152

153153
@Generated("org.mybatis.generator.api.MyBatisGenerator")
154154
default int updateByPrimaryKey(BoardVO row) {
155155
return update(c ->
156156
c.set(title).equalTo(row::getTitle)
157-
.set(content).equalTo(row::getContent)
158157
.set(writer).equalTo(row::getWriter)
159158
.set(regdate).equalTo(row::getRegdate)
160159
.set(updateDate).equalTo(row::getUpdateDate)
161160
.set(replyCount).equalTo(row::getReplyCount)
161+
.set(content).equalTo(row::getContent)
162162
.where(bno, isEqualTo(row::getBno))
163163
);
164164
}
@@ -167,11 +167,11 @@ default int updateByPrimaryKey(BoardVO row) {
167167
default int updateByPrimaryKeySelective(BoardVO row) {
168168
return update(c ->
169169
c.set(title).equalToWhenPresent(row::getTitle)
170-
.set(content).equalToWhenPresent(row::getContent)
171170
.set(writer).equalToWhenPresent(row::getWriter)
172171
.set(regdate).equalToWhenPresent(row::getRegdate)
173172
.set(updateDate).equalToWhenPresent(row::getUpdateDate)
174173
.set(replyCount).equalToWhenPresent(row::getReplyCount)
174+
.set(content).equalToWhenPresent(row::getContent)
175175
.where(bno, isEqualTo(row::getBno))
176176
);
177177
}

part-last/my-board-mds/src/main/java/org/fp024/mapper/generated/BoardVODynamicSqlSupport.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public final class BoardVODynamicSqlSupport {
1616
@Generated("org.mybatis.generator.api.MyBatisGenerator")
1717
public static final SqlColumn<String> title = boardVO.title;
1818

19-
@Generated("org.mybatis.generator.api.MyBatisGenerator")
20-
public static final SqlColumn<String> content = boardVO.content;
21-
2219
@Generated("org.mybatis.generator.api.MyBatisGenerator")
2320
public static final SqlColumn<String> writer = boardVO.writer;
2421

@@ -31,14 +28,15 @@ public final class BoardVODynamicSqlSupport {
3128
@Generated("org.mybatis.generator.api.MyBatisGenerator")
3229
public static final SqlColumn<Integer> replyCount = boardVO.replyCount;
3330

31+
@Generated("org.mybatis.generator.api.MyBatisGenerator")
32+
public static final SqlColumn<String> content = boardVO.content;
33+
3434
@Generated("org.mybatis.generator.api.MyBatisGenerator")
3535
public static final class BoardVO extends AliasableSqlTable<BoardVO> {
3636
public final SqlColumn<Long> bno = column("BNO", JDBCType.NUMERIC);
3737

3838
public final SqlColumn<String> title = column("TITLE", JDBCType.VARCHAR);
3939

40-
public final SqlColumn<String> content = column("CONTENT", JDBCType.VARCHAR);
41-
4240
public final SqlColumn<String> writer = column("WRITER", JDBCType.VARCHAR);
4341

4442
public final SqlColumn<LocalDateTime> regdate = column("REGDATE", JDBCType.TIMESTAMP);
@@ -47,6 +45,8 @@ public static final class BoardVO extends AliasableSqlTable<BoardVO> {
4745

4846
public final SqlColumn<Integer> replyCount = column("REPLYCNT", JDBCType.NUMERIC);
4947

48+
public final SqlColumn<String> content = column("CONTENT", JDBCType.CLOB);
49+
5050
public BoardVO() {
5151
super("TBL_BOARD", BoardVO::new);
5252
}

part-last/my-board-mds/src/test/java/org/fp024/mapper/BoardMapperTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void testCreateSearchWhereClause_T_C_W() {
188188
"select ROWNUM as rn, BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT"
189189
+ " from TBL_BOARD"
190190
+ " where (TITLE like #{parameters.p1,jdbcType=VARCHAR}"
191-
+ " or CONTENT like #{parameters.p2,jdbcType=VARCHAR}"
191+
+ " or CONTENT like #{parameters.p2,jdbcType=CLOB}"
192192
+ " or WRITER like #{parameters.p3,jdbcType=VARCHAR})"
193193
+ " and ROWNUM <= #{parameters.p4}",
194194
selectStatement.getSelectStatement());
@@ -218,7 +218,7 @@ void testCreateSearchWhereClause_T_C() {
218218
"select ROWNUM as rn, BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT"
219219
+ " from TBL_BOARD"
220220
+ " where (TITLE like #{parameters.p1,jdbcType=VARCHAR}"
221-
+ " or CONTENT like #{parameters.p2,jdbcType=VARCHAR})"
221+
+ " or CONTENT like #{parameters.p2,jdbcType=CLOB})"
222222
+ " and ROWNUM <= #{parameters.p3}",
223223
selectStatement.getSelectStatement());
224224

@@ -273,7 +273,7 @@ void testCreateSearchWhereClause_C() {
273273
assertEquals(
274274
"select ROWNUM as rn, BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT"
275275
+ " from TBL_BOARD"
276-
+ " where CONTENT like #{parameters.p1,jdbcType=VARCHAR}"
276+
+ " where CONTENT like #{parameters.p1,jdbcType=CLOB}"
277277
+ " and ROWNUM <= #{parameters.p2}",
278278
selectStatement.getSelectStatement());
279279

@@ -366,7 +366,7 @@ void testWhere() {
366366
"select ROWNUM as rn, BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT"
367367
+ " from TBL_BOARD"
368368
+ " where TITLE like #{parameters.p1,jdbcType=VARCHAR}"
369-
+ " or CONTENT like #{parameters.p2,jdbcType=VARCHAR}"
369+
+ " or CONTENT like #{parameters.p2,jdbcType=CLOB}"
370370
+ " or WRITER like #{parameters.p3,jdbcType=VARCHAR}"
371371
+ " and ROWNUM <= #{parameters.p4}",
372372
selectStatement.getSelectStatement());
@@ -406,7 +406,7 @@ void testWhereWithParentheses() {
406406
"select ROWNUM as rn, BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT"
407407
+ " from TBL_BOARD"
408408
+ " where (TITLE like #{parameters.p1,jdbcType=VARCHAR}"
409-
+ " or CONTENT like #{parameters.p2,jdbcType=VARCHAR}"
409+
+ " or CONTENT like #{parameters.p2,jdbcType=CLOB}"
410410
+ " or WRITER like #{parameters.p3,jdbcType=VARCHAR})"
411411
+ " and ROWNUM <= #{parameters.p4}",
412412
selectStatement.getSelectStatement());

part-last/my-board-mds/src/test/java/org/fp024/service/BoardServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ void testAddSearchWhereClause_getListQuery() {
129129

130130
SelectStatementProvider selectStatementProvider = getListSqlDSL(criteria);
131131
assertEquals(
132-
"select BNO, TITLE, CONTENT, WRITER, REGDATE, UPDATEDATE, REPLYCNT from (select /*+"
132+
"select BNO, TITLE, WRITER, REGDATE, UPDATEDATE, REPLYCNT, CONTENT from (select /*+"
133133
+ " INDEX_DESC(tbl_board pk_board) */ 'dummy', ROWNUM as rn, BNO, TITLE, CONTENT,"
134134
+ " WRITER, REGDATE, UPDATEDATE, REPLYCNT from TBL_BOARD where (TITLE like"
135-
+ " #{parameters.p1,jdbcType=VARCHAR} or CONTENT like #{parameters.p2,jdbcType=VARCHAR}"
135+
+ " #{parameters.p1,jdbcType=VARCHAR} or CONTENT like #{parameters.p2,jdbcType=CLOB}"
136136
+ " or WRITER like #{parameters.p3,jdbcType=VARCHAR}) and ROWNUM <= #{parameters.p4})"
137137
+ " where rn > #{parameters.p5} order by BNO DESC",
138138
selectStatementProvider.getSelectStatement());

part-last/my-board-mds/src/test/java/org/fp024/util/CommonUtilTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void testGetFolder() {
2828

2929
@Test
3030
void testGetUUID() {
31-
// IntelliJ에서 JUnit으로 실행할 때, ${project.basedir}/.nvm/jvm.config 의 설정을 사용하는 것 같지는 않다.
31+
// IntelliJ에서 JUnit으로 실행할 때, ${project.basedir}/.mvn/jvm.config 의 설정을 사용하는 것 같지는 않다.
3232
IntStream.rangeClosed(1, 10).forEach(i -> LOGGER.info("UUID: {}", CommonUtil.getUUID()));
3333
}
3434
}

0 commit comments

Comments
 (0)