protected void bindPrimaryKey(BoundStatement boundStatement, AtreusManagedEntity managedEntity) { AtreusMetaEntity metaEntity = managedEntity.getMetaEntity(); AtreusMetaField primaryKeyMetaField = metaEntity.getPrimaryKeyField(); for (AtreusMetaField metaField : iterateMetaSimpleFields(primaryKeyMetaField)) { metaField.bindValue(boundStatement, metaField.getValue(managedEntity)); } }
protected boolean hasTtl(AtreusManagedEntity managedEntity) { AtreusMetaEntity metaEntity = managedEntity.getMetaEntity(); AtreusMetaField ttlMetaField = metaEntity.getTtlField(); if (ttlMetaField != null && managedEntity.getFieldValue(ttlMetaField) != null) { return true; } return false; }
@SuppressWarnings("unchecked") protected void bindTtl(AtreusManagedEntity managedEntity, BoundStatement boundStatement) { AtreusMetaEntity metaEntity = managedEntity.getMetaEntity(); AtreusMetaField ttlMetaField = metaEntity.getTtlField(); if (ttlMetaField == null) { return; } Object value = managedEntity.getFieldValue(ttlMetaField); if (value == null) { return; } Integer ttlValue = metaEntity.getTtlStrategy().translate(new Date(), value); if (ttlValue == null || ttlValue < 1) { throw new AtreusDataBindingException( AtreusDataBindingException.ERROR_CODE_INVALID_TIME_TO_LIVE_VALUE, ttlMetaField, ttlValue); } ttlMetaField.bindValue(boundStatement, ttlValue); }
protected void bindColumnsAll(BoundStatement boundStatement, AtreusManagedEntity managedEntity) { AtreusMetaEntity metaEntity = managedEntity.getMetaEntity(); for (AtreusMetaField metaField : iterateMetaSimpleFields(metaEntity.getFields())) { metaField.bindEntity(boundStatement, managedEntity); } }