Skip to content

Commit 7fde74b

Browse files
committed
Add and polish the Options classes
1 parent a7b464c commit 7fde74b

20 files changed

+76
-29
lines changed

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/Entityql.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.seasar.doma.jdbc.Config;
77
import org.seasar.doma.jdbc.criteria.context.Options;
88
import org.seasar.doma.jdbc.criteria.context.SelectContext;
9+
import org.seasar.doma.jdbc.criteria.context.SelectOptions;
910
import org.seasar.doma.jdbc.criteria.declaration.SelectFromDeclaration;
1011
import org.seasar.doma.jdbc.criteria.def.EntityDef;
1112
import org.seasar.doma.jdbc.criteria.statement.EntityqlBatchDeleteStatement;
@@ -31,7 +32,7 @@ public <ENTITY> EntityqlSelectStatement<ENTITY> from(EntityDef<ENTITY> entityDef
3132
}
3233

3334
public <ENTITY> EntityqlSelectStatement<ENTITY> from(
34-
EntityDef<ENTITY> entityDef, Consumer<Options> optionsConsumer) {
35+
EntityDef<ENTITY> entityDef, Consumer<SelectOptions> optionsConsumer) {
3536
Objects.requireNonNull(entityDef);
3637
Objects.requireNonNull(optionsConsumer);
3738
SelectContext context = new SelectContext(entityDef);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.seasar.doma.jdbc.criteria.context;
2+
3+
public class DeleteOptions {
4+
int batchSize = 0;
5+
boolean emptyWhereAllowable;
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.seasar.doma.jdbc.criteria.context;
2+
3+
public class InsertOptions {
4+
int batchSize = 0;
5+
6+
public int getBatchSize() {
7+
return batchSize;
8+
}
9+
10+
public void setBatchSize(int batchSize) {
11+
this.batchSize = batchSize;
12+
}
13+
}
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
package org.seasar.doma.jdbc.criteria.context;
22

3-
import java.util.Objects;
43
import org.seasar.doma.jdbc.SqlLogType;
54

65
public class Options {
7-
86
private String comment;
97
private SqlLogType sqlLogType = SqlLogType.FORMATTED;
8+
private int queryTimeout = 0;
109

11-
public String comment() {
10+
public String getComment() {
1211
return comment;
1312
}
1413

15-
public void comment(String comment) {
14+
public void setComment(String comment) {
1615
this.comment = comment;
1716
}
1817

19-
public SqlLogType sqlLogType() {
18+
public SqlLogType getSqlLogType() {
2019
return sqlLogType;
2120
}
2221

23-
public void sqlLogType(SqlLogType sqlLogType) {
24-
this.sqlLogType = Objects.requireNonNull(sqlLogType);
22+
public void setSqlLogType(SqlLogType sqlLogType) {
23+
this.sqlLogType = sqlLogType;
24+
}
25+
26+
public int getQueryTimeout() {
27+
return queryTimeout;
28+
}
29+
30+
public void setQueryTimeout(int queryTimeout) {
31+
this.queryTimeout = queryTimeout;
2532
}
2633
}

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/context/SelectContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class SelectContext implements Context {
2727
public ForUpdate forUpdate;
2828
public final Map<Pair<EntityDef<?>, EntityDef<?>>, BiConsumer<Object, Object>> associations =
2929
new LinkedHashMap<>();
30-
public final Options options = new Options();
30+
public final SelectOptions options = new SelectOptions();
3131

3232
public SelectContext(EntityDef<?> entityDef) {
3333
this(entityDef, Projection.All);
@@ -60,7 +60,7 @@ public void setWhere(List<Criterion> where) {
6060
}
6161

6262
@Override
63-
public Options getOptions() {
63+
public SelectOptions getOptions() {
6464
return options;
6565
}
6666

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.seasar.doma.jdbc.criteria.context;
2+
3+
public class SelectOptions extends Options {
4+
private int fetchSize = 0;
5+
private int maxRows = 0;
6+
7+
public int getFetchSize() {
8+
return fetchSize;
9+
}
10+
11+
public void setFetchSize(int fetchSize) {
12+
this.fetchSize = fetchSize;
13+
}
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.seasar.doma.jdbc.criteria.context;
2+
3+
public class UpdateOptions extends Options {
4+
int batchSize = 0;
5+
boolean emptyWhereAllowable;
6+
}

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/statement/EntityqlBatchDeleteStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ protected Command<List<ENTITY>> createCommand() {
4141
query.setCallerMethodName(EXECUTE_METHOD_NAME);
4242
query.setQueryTimeout(config.getQueryTimeout());
4343
query.setBatchSize(config.getBatchSize());
44-
query.setSqlLogType(options.sqlLogType());
44+
query.setSqlLogType(options.getSqlLogType());
4545
query.setVersionIgnored(false);
4646
query.setOptimisticLockExceptionSuppressed(false);
47-
query.setMessage(options.comment());
47+
query.setMessage(options.getComment());
4848
query.prepare();
4949
BatchDeleteCommand command =
5050
config.getCommandImplementors().createBatchDeleteCommand(EXECUTE_METHOD, query);

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/statement/EntityqlBatchInsertStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ protected Command<List<ENTITY>> createCommand() {
4141
query.setCallerMethodName(EXECUTE_METHOD_NAME);
4242
query.setQueryTimeout(config.getQueryTimeout());
4343
query.setBatchSize(config.getBatchSize());
44-
query.setSqlLogType(options.sqlLogType());
44+
query.setSqlLogType(options.getSqlLogType());
4545
query.setIncludedPropertyNames();
4646
query.setExcludedPropertyNames();
47-
query.setMessage(options.comment());
47+
query.setMessage(options.getComment());
4848
query.prepare();
4949
BatchInsertCommand command =
5050
config.getCommandImplementors().createBatchInsertCommand(EXECUTE_METHOD, query);

doma-core/src/main/java/org/seasar/doma/jdbc/criteria/statement/EntityqlBatchUpdateStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ protected Command<List<ENTITY>> createCommand() {
4141
query.setCallerMethodName(EXECUTE_METHOD_NAME);
4242
query.setQueryTimeout(config.getQueryTimeout());
4343
query.setBatchSize(config.getBatchSize());
44-
query.setSqlLogType(options.sqlLogType());
44+
query.setSqlLogType(options.getSqlLogType());
4545
query.setVersionIgnored(false);
4646
query.setIncludedPropertyNames();
4747
query.setExcludedPropertyNames();
4848
query.setOptimisticLockExceptionSuppressed(false);
49-
query.setMessage(options.comment());
49+
query.setMessage(options.getComment());
5050
query.prepare();
5151
BatchUpdateCommand command =
5252
config.getCommandImplementors().createBatchUpdateCommand(EXECUTE_METHOD, query);

0 commit comments

Comments
 (0)