private void maybeRebuildCache(CodecRegistry codecRegistry) { if (!dirty && cache != null) return; StringBuilder sb; values = null; if (hasBindMarkers || forceNoValues) { sb = buildQueryString(null, codecRegistry); } else { values = new ArrayList<Object>(); sb = buildQueryString(values, codecRegistry); if (values.size() > 65535) throw new IllegalArgumentException( "Too many values for built statement, the maximum allowed is 65535"); if (values.isEmpty()) values = null; } maybeAddSemicolon(sb); cache = sb.toString(); dirty = false; }
@Override public String toString() { try { if (forceNoValues) return getQueryString(); // 1) try first with all values inlined (will not work if some values require custom codecs, // or if the required codecs are registered in a different CodecRegistry instance than the // default one) return maybeAddSemicolon(buildQueryString(null, CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e1) { // 2) try next with bind markers for all values to avoid usage of custom codecs try { return maybeAddSemicolon( buildQueryString(new ArrayList<Object>(), CodecRegistry.DEFAULT_INSTANCE)) .toString(); } catch (RuntimeException e2) { // Ugly but we have absolutely no context to get the registry from return String.format( "built query (could not generate with default codec registry: %s)", e2.getMessage()); } } }
@Override public String toString() { try { if (forceNoValues) return getQueryString(); // 1) try first with all values inlined (will not work if some values require custom codecs, // or if the required codecs are registered in a different CodecRegistry instance than the default one) return maybeAddSemicolon(buildQueryString(null, CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e1) { // 2) try next with bind markers for all values to avoid usage of custom codecs try { return maybeAddSemicolon(buildQueryString(new ArrayList<Object>(), CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e2) { // Ugly but we have absolutely no context to get the registry from return String.format("built query (could not generate with default codec registry: %s)", e2.getMessage()); } } }
@Override public String toString() { try { if (forceNoValues) return getQueryString(); // 1) try first with all values inlined (will not work if some values require custom codecs, // or if the required codecs are registered in a different CodecRegistry instance than the default one) return maybeAddSemicolon(buildQueryString(null, CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e1) { // 2) try next with bind markers for all values to avoid usage of custom codecs try { return maybeAddSemicolon(buildQueryString(new ArrayList<Object>(), CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e2) { // Ugly but we have absolutely no context to get the registry from return String.format("built query (could not generate with default codec registry: %s)", e2.getMessage()); } } }
@Override public String toString() { if (forceNoValues) return getQueryString(); return maybeAddSemicolon(buildQueryString(null)).toString(); }
private void maybeRebuildCache() { if (!dirty && cache != null) return; StringBuilder sb; values = null; if (hasBindMarkers || forceNoValues) { sb = buildQueryString(null); } else { List<ByteBuffer> l = new ArrayList<ByteBuffer>(); sb = buildQueryString(l); if (!l.isEmpty()) values = l.toArray(new ByteBuffer[l.size()]); } maybeAddSemicolon(sb); cache = sb.toString(); dirty = false; }
@Override public String toString() { try { if (forceNoValues) return getQueryString(); // 1) try first with all values inlined (will not work if some values require custom codecs, // or if the required codecs are registered in a different CodecRegistry instance than the default one) return maybeAddSemicolon(buildQueryString(null, CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e1) { // 2) try next with bind markers for all values to avoid usage of custom codecs try { return maybeAddSemicolon(buildQueryString(new ArrayList<Object>(), CodecRegistry.DEFAULT_INSTANCE)).toString(); } catch (RuntimeException e2) { // Ugly but we have absolutely no context to get the registry from return String.format("built query (could not generate with default codec registry: %s)", e2.getMessage()); } } }
private void maybeRebuildCache(CodecRegistry codecRegistry) { if (!dirty && cache != null) return; StringBuilder sb; values = null; if (hasBindMarkers || forceNoValues) { sb = buildQueryString(null, codecRegistry); } else { values = new ArrayList<Object>(); sb = buildQueryString(values, codecRegistry); if (values.size() > 65535) throw new IllegalArgumentException("Too many values for built statement, the maximum allowed is 65535"); if (values.isEmpty()) values = null; } maybeAddSemicolon(sb); cache = sb.toString(); dirty = false; }
private void maybeRebuildCache(CodecRegistry codecRegistry) { if (!dirty && cache != null) return; StringBuilder sb; values = null; if (hasBindMarkers || forceNoValues) { sb = buildQueryString(null, codecRegistry); } else { values = new ArrayList<Object>(); sb = buildQueryString(values, codecRegistry); if (values.size() > 65535) throw new IllegalArgumentException("Too many values for built statement, the maximum allowed is 65535"); if (values.isEmpty()) values = null; } maybeAddSemicolon(sb); cache = sb.toString(); dirty = false; }
private void maybeRebuildCache(CodecRegistry codecRegistry) { if (!dirty && cache != null) return; StringBuilder sb; values = null; if (hasBindMarkers || forceNoValues) { sb = buildQueryString(null, codecRegistry); } else { values = new ArrayList<Object>(); sb = buildQueryString(values, codecRegistry); if (values.size() > 65535) throw new IllegalArgumentException("Too many values for built statement, the maximum allowed is 65535"); if (values.isEmpty()) values = null; } maybeAddSemicolon(sb); cache = sb.toString(); dirty = false; }