Search in sources :

Example 11 with StructField

use of com.google.cloud.spanner.Type.StructField in project jans by JanssenProject.

the class SpannerConnectionProvider method getTableMappingByKey.

public TableMapping getTableMappingByKey(String key, String objectClass, String tableName) {
    Map<String, StructField> columTypes = tableColumnsMap.get(tableName);
    if (!tableColumnsMap.containsKey(tableName)) {
        throw new MappingException(String.format("Table '%s' metadata is not exists '", tableName));
    }
    if ("_".equals(key)) {
        return new TableMapping("", tableName, objectClass, columTypes);
    }
    String[] baseNameParts = key.split("_");
    if (ArrayHelper.isEmpty(baseNameParts)) {
        throw new KeyConversionException("Failed to determine base key part!");
    }
    TableMapping tableMapping = new TableMapping(baseNameParts[0], tableName, objectClass, columTypes);
    return tableMapping;
}
Also used : StructField(com.google.cloud.spanner.Type.StructField) KeyConversionException(io.jans.orm.exception.KeyConversionException) TableMapping(io.jans.orm.cloud.spanner.model.TableMapping) MappingException(io.jans.orm.exception.MappingException)

Aggregations

StructField (com.google.cloud.spanner.Type.StructField)11 ValueWithStructField (io.jans.orm.cloud.spanner.model.ValueWithStructField)7 TableMapping (io.jans.orm.cloud.spanner.model.TableMapping)5 SpannerException (com.google.cloud.spanner.SpannerException)4 ArrayList (java.util.ArrayList)4 ResultSet (com.google.cloud.spanner.ResultSet)3 PersistenceException (io.jans.orm.exception.operation.PersistenceException)3 SearchException (io.jans.orm.exception.operation.SearchException)3 AttributeData (io.jans.orm.model.AttributeData)3 LinkedList (java.util.LinkedList)3 Mutation (com.google.cloud.spanner.Mutation)2 WriteBuilder (com.google.cloud.spanner.Mutation.WriteBuilder)2 Struct (com.google.cloud.spanner.Struct)2 Code (com.google.cloud.spanner.Type.Code)2 MessageDigest (java.security.MessageDigest)2 KeySet (com.google.cloud.spanner.KeySet)1 Builder (com.google.cloud.spanner.Statement.Builder)1 Type (com.google.cloud.spanner.Type)1 KeyConversionException (io.jans.orm.exception.KeyConversionException)1 MappingException (io.jans.orm.exception.MappingException)1