@Override public PrimaryKey getPrimaryKey() { Map<Schema.Field, Object> values = new HashMap<>(); values.put(NAME_FIELD, name); return new PrimaryKey(values); }
private List<String> getPrimaryColumns(Storable storable, final String formatter) { return storable.getPrimaryKey().getFieldsToVal().keySet().stream().map( colField -> String.format(formatter, colField.getName())).collect(Collectors.toList()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StorableKey that = (StorableKey) o; if (primaryKey != null ? !primaryKey.equals(that.primaryKey) : that.primaryKey != null) return false; return !(nameSpace != null ? !nameSpace.equals(that.nameSpace) : that.nameSpace != null); }
@Override public int hashCode() { int result = primaryKey != null ? primaryKey.hashCode() : 0; result = 31 * result + (nameSpace != null ? nameSpace.hashCode() : 0); return result; }
@Override public int hashCode() { int result = primaryKey != null ? primaryKey.hashCode() : 0; result = 31 * result + (nameSpace != null ? nameSpace.hashCode() : 0); return result; }
@Override @JsonIgnore public PrimaryKey getPrimaryKey() { return new PrimaryKey(Collections.<Schema.Field, Object>singletonMap(NAME_FIELD, name)); }
private List<String> getPrimaryColumns(Storable storable, final String formatter) { return storable.getPrimaryKey().getFieldsToVal().keySet().stream().map( colField -> String.format(formatter, colField.getName())).collect(Collectors.toList()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; StorableKey that = (StorableKey) o; if (primaryKey != null ? !primaryKey.equals(that.primaryKey) : that.primaryKey != null) return false; return !(nameSpace != null ? !nameSpace.equals(that.nameSpace) : that.nameSpace != null); }
@Override public int hashCode() { int result = columns != null ? columns.hashCode() : 0; result = 31 * result + (tableName != null ? tableName.hashCode() : 0); result = 31 * result + (primaryKey != null ? primaryKey.hashCode() : 0); return result; }
@JsonIgnore @Override public PrimaryKey getPrimaryKey() { Map<Schema.Field, Object> fieldToObjectMap = new HashMap<>(); fieldToObjectMap.put(new Schema.Field(USER_ID, Schema.Type.LONG), userId); return new PrimaryKey(fieldToObjectMap); }
public AbstractStorableKeyQuery(StorableKey storableKey) { tableName = storableKey.getNameSpace(); primaryKey = storableKey.getPrimaryKey(); columns = new LinkedList<>(storableKey.getPrimaryKey().getFieldsToVal().keySet()); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AbstractSqlQuery that = (AbstractSqlQuery) o; if (columns != null ? !columns.equals(that.columns) : that.columns != null) return false; if (tableName != null ? !tableName.equals(that.tableName) : that.tableName != null) return false; return !(primaryKey != null ? !primaryKey.equals(that.primaryKey) : that.primaryKey != null); }
@Override public int hashCode() { int result = columns != null ? columns.hashCode() : 0; result = 31 * result + (tableName != null ? tableName.hashCode() : 0); result = 31 * result + (primaryKey != null ? primaryKey.hashCode() : 0); return result; }
@JsonIgnore @Override public PrimaryKey getPrimaryKey() { Map<Schema.Field, Object> fieldToObjectMap = new HashMap<>(); fieldToObjectMap.put(new Schema.Field(ID, Schema.Type.LONG), this.id); return new PrimaryKey(fieldToObjectMap); }
public AbstractStorableKeyQuery(StorableKey storableKey) { tableName = storableKey.getNameSpace(); primaryKey = storableKey.getPrimaryKey(); columns = new LinkedList<>(storableKey.getPrimaryKey().getFieldsToVal().keySet()); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AbstractSqlQuery that = (AbstractSqlQuery) o; if (columns != null ? !columns.equals(that.columns) : that.columns != null) return false; if (tableName != null ? !tableName.equals(that.tableName) : that.tableName != null) return false; return !(primaryKey != null ? !primaryKey.equals(that.primaryKey) : that.primaryKey != null); }
@JsonIgnore public PrimaryKey getPrimaryKey() { Map<Schema.Field, Object> fieldToObjectMap = new HashMap<>(); fieldToObjectMap.put(new Schema.Field("id", Schema.Type.LONG), this.id); return new PrimaryKey(fieldToObjectMap); }
public AbstractStorableUpdateQuery(Storable storable) { super(storable); Map<String, Object> columnsToValues = storable.toMap(); columns.forEach(col -> bindings.add(Pair.of(col, columnsToValues.get(col.getName())))); primaryKey.getFieldsToVal().forEach((f, o) -> { bindings.add(Pair.of(f, o)); whereFields.add(f); }); try { Optional<Pair<Field, Long>> versionFieldValue = StorageUtils.getVersionFieldValue(storable); if (versionFieldValue.isPresent()) { Pair<Field, Long> fv = versionFieldValue.get(); Schema.Field versionField = Schema.Field.of(fv.getKey().getName(), Schema.fromJavaType(fv.getValue().getClass())); whereFields.add(versionField); // update only if its the previous bindings.add(Pair.of(versionField, fv.getValue() - 1)); } } catch (Exception ex) { LOG.error("Got exception", ex); } }
@JsonIgnore @Override public PrimaryKey getPrimaryKey() { Map<Schema.Field, Object> fieldToObjectMap = new HashMap<>(); fieldToObjectMap.put(new Schema.Field("id", Schema.Type.LONG), this.id); return new PrimaryKey(fieldToObjectMap); }
public AbstractStorableUpdateQuery(Storable storable) { super(storable); Map<String, Object> columnsToValues = storable.toMap(); columns.forEach(col -> bindings.add(Pair.of(col, columnsToValues.get(col.getName())))); primaryKey.getFieldsToVal().forEach((f, o) -> { bindings.add(Pair.of(f, o)); whereFields.add(f); }); try { Optional<Pair<Field, Long>> versionFieldValue = StorageUtils.getVersionFieldValue(storable); if (versionFieldValue.isPresent()) { Pair<Field, Long> fv = versionFieldValue.get(); Schema.Field versionField = Schema.Field.of(fv.getKey().getName(), Schema.fromJavaType(fv.getValue().getClass())); whereFields.add(versionField); // update only if its the previous bindings.add(Pair.of(versionField, fv.getValue() - 1)); } } catch (Exception ex) { LOG.error("Got exception", ex); } }