diff --git a/jOOQ/src/main/java/org/jooq/conf/Settings.java b/jOOQ/src/main/java/org/jooq/conf/Settings.java index f9813f9e86..236aaa12be 100644 --- a/jOOQ/src/main/java/org/jooq/conf/Settings.java +++ b/jOOQ/src/main/java/org/jooq/conf/Settings.java @@ -80,6 +80,8 @@ public class Settings @XmlElement(defaultValue = "PREPARED_STATEMENT") @XmlSchemaType(name = "string") protected StatementType statementType = StatementType.PREPARED_STATEMENT; + @XmlElement(defaultValue = "0") + protected Integer inlineThreshold = 0; @XmlElement(defaultValue = "true") protected Boolean executeLogging = true; @XmlElement(defaultValue = "false") @@ -604,6 +606,38 @@ public class Settings this.statementType = value; } + /** + * The maximum number of allowed bind variables before inlining all values where 0 uses the dialect defaults: + * + * @return + * possible object is + * {@link Integer } + * + */ + public Integer getInlineThreshold() { + return inlineThreshold; + } + + /** + * Sets the value of the inlineThreshold property. + * + * @param value + * allowed object is + * {@link Integer } + * + */ + public void setInlineThreshold(Integer value) { + this.inlineThreshold = value; + } + /** * When set to true, this will add jOOQ's default logging ExecuteListeners. * @@ -1424,6 +1458,11 @@ public class Settings return this; } + public Settings withInlineThreshold(Integer value) { + setInlineThreshold(value); + return this; + } + public Settings withExecuteLogging(Boolean value) { setExecuteLogging(value); return this; @@ -1662,6 +1701,11 @@ public class Settings sb.append(statementType); sb.append(""); } + if (inlineThreshold!= null) { + sb.append(""); + sb.append(inlineThreshold); + sb.append(""); + } if (executeLogging!= null) { sb.append(""); sb.append(executeLogging); @@ -1980,6 +2024,15 @@ public class Settings return false; } } + if (inlineThreshold == null) { + if (other.inlineThreshold!= null) { + return false; + } + } else { + if (!inlineThreshold.equals(other.inlineThreshold)) { + return false; + } + } if (executeLogging == null) { if (other.executeLogging!= null) { return false; @@ -2274,6 +2327,7 @@ public class Settings result = ((prime*result)+((paramType == null)? 0 :paramType.hashCode())); result = ((prime*result)+((paramCastMode == null)? 0 :paramCastMode.hashCode())); result = ((prime*result)+((statementType == null)? 0 :statementType.hashCode())); + result = ((prime*result)+((inlineThreshold == null)? 0 :inlineThreshold.hashCode())); result = ((prime*result)+((executeLogging == null)? 0 :executeLogging.hashCode())); result = ((prime*result)+((executeWithOptimisticLocking == null)? 0 :executeWithOptimisticLocking.hashCode())); result = ((prime*result)+((executeWithOptimisticLockingExcludeUnversioned == null)? 0 :executeWithOptimisticLockingExcludeUnversioned.hashCode())); diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java index 3d0fce23a5..cff44ac70f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultRenderContext.java @@ -526,7 +526,12 @@ class DefaultRenderContext extends AbstractContext implements Ren if (!param.isInline()) { bindValues.add(param); - switch (family()) { + Integer threshold = settings().getInlineThreshold(); + if (threshold != null && threshold > 0) { + checkForceInline(threshold); + } + else { + switch (family()) { @@ -554,17 +559,18 @@ class DefaultRenderContext extends AbstractContext implements Ren - // [#5701] Tests were conducted with PostgreSQL 9.5 and pgjdbc 9.4.1209 - case POSTGRES: - checkForceInline(32767); - break; + // [#5701] Tests were conducted with PostgreSQL 9.5 and pgjdbc 9.4.1209 + case POSTGRES: + checkForceInline(32767); + break; - case SQLITE: - checkForceInline(999); - break; + case SQLITE: + checkForceInline(999); + break; - default: - break; + default: + break; + } } } } diff --git a/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd b/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd index b3c950451e..e0fcf7ec78 100644 --- a/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd +++ b/jOOQ/src/main/resources/xsd/jooq-runtime-3.12.0.xsd @@ -127,6 +127,18 @@ case of which, this defaults to INLINED]]> + + 0 uses the dialect defaults:
    +
  • {@link org.jooq.SQLDialect#ACCESS} : 768
  • +
  • {@link org.jooq.SQLDialect#ASE} : 2000
  • +
  • {@link org.jooq.SQLDialect#INGRES} : 1024
  • +
  • {@link org.jooq.SQLDialect#ORACLE} : 32767
  • +
  • {@link org.jooq.SQLDialect#POSTGRES} : 32767
  • +
  • {@link org.jooq.SQLDialect#SQLITE} : 999
  • +
  • {@link org.jooq.SQLDialect#SQLSERVER} : 2100
  • +
]]>
+
+