Java Code Examples for com.google.cloud.spanner.Key#Builder
The following examples show how to use
com.google.cloud.spanner.Key#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConverterAwareMappingSpannerEntityWriter.java From spring-cloud-gcp with Apache License 2.0 | 6 votes |
@Override public Key convertToKey(Object key) { Assert.notNull(key, "Key of an entity to be written cannot be null!"); Key k; boolean isIterable = Iterable.class.isAssignableFrom(key.getClass()); boolean isArray = Object[].class.isAssignableFrom(key.getClass()); if ((isIterable || isArray) && !ByteArray.class.isAssignableFrom(key.getClass())) { Key.Builder kb = Key.newBuilder(); for (Object keyPart : (isArray ? (Arrays.asList((Object[]) key)) : ((Iterable) key))) { kb.appendObject(convertKeyPart(keyPart)); } k = kb.build(); if (k.size() == 0) { throw new SpannerDataException( "A key must have at least one component, but 0 were given."); } } else { k = Key.class.isAssignableFrom(key.getClass()) ? (Key) key : Key.of(convertKeyPart(key)); } return k; }
Example 2
Source File: DeleteKeyBuilder.java From spanner-jdbc with MIT License | 5 votes |
public Key.Builder getKeyBuilder() throws SQLException { Key.Builder builder = Key.newBuilder(); for (String key : table.getKeyColumns()) { Object value = keyValues.get(key); if (!generateParameterMetaData && value == null && !keyValues.containsKey(key)) { throw new CloudSpannerSQLException( "No value supplied for key column " + key + ". All key columns must be specified in the WHERE-clause of a DELETE-statement.", Code.INVALID_ARGUMENT); } builder.appendObject(convert(value)); } return builder; }