Search in sources :

Example 16 with TableMapping

use of io.jans.orm.cloud.spanner.model.TableMapping in project jans by JanssenProject.

the class SpannerConnectionProvider method getChildTableMappingByKey.

public TableMapping getChildTableMappingByKey(String key, TableMapping tableMapping, String columnName) {
    String childTableName = tableMapping.getTableName() + "_" + columnName;
    TableMapping childTableMapping = getTableMappingByKey(key, tableMapping.getObjectClass(), childTableName);
    return childTableMapping;
}
Also used : TableMapping(io.jans.orm.cloud.spanner.model.TableMapping)

Example 17 with TableMapping

use of io.jans.orm.cloud.spanner.model.TableMapping 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

TableMapping (io.jans.orm.cloud.spanner.model.TableMapping)17 Duration (java.time.Duration)8 Instant (java.time.Instant)8 StructField (com.google.cloud.spanner.Type.StructField)5 ValueWithStructField (io.jans.orm.cloud.spanner.model.ValueWithStructField)4 AttributeData (io.jans.orm.model.AttributeData)4 SearchException (io.jans.orm.exception.operation.SearchException)3 LinkedList (java.util.LinkedList)3 Mutation (com.google.cloud.spanner.Mutation)2 WriteBuilder (com.google.cloud.spanner.Mutation.WriteBuilder)2 SpannerException (com.google.cloud.spanner.SpannerException)2 PersistenceException (io.jans.orm.exception.operation.PersistenceException)2 MessageDigest (java.security.MessageDigest)2 Column (net.sf.jsqlparser.schema.Column)2 KeySet (com.google.cloud.spanner.KeySet)1 Builder (com.google.cloud.spanner.Statement.Builder)1 KeyConversionException (io.jans.orm.exception.KeyConversionException)1 MappingException (io.jans.orm.exception.MappingException)1 EntryConvertationException (io.jans.orm.exception.operation.EntryConvertationException)1 AttributeDataModification (io.jans.orm.model.AttributeDataModification)1