public boolean ignore() { return has(IgnoreProperty.class); }
public boolean ignore() { return has(IgnoreProperty.class); }
public boolean isKey() { return has(KeyProperty.class); }
public boolean isKey() { return has(KeyProperty.class); }
public void successfullyMapAtLeastToOne(ColumnDefinition<?, ?> columnDefinition) { try { if (errorCollector.size() == nbBuilders && ! columnDefinition.has(OptionalProperty.class)) { PropertyNotFound propertyNotFound = errorCollector.get(0); delegate.propertyNotFound(propertyNotFound.target, propertyNotFound.property); } } finally { errorCollector.clear(); } }
public void successfullyMapAtLeastToOne(ColumnDefinition<?, ?> columnDefinition) { try { if (errorCollector.size() == nbBuilders && ! columnDefinition.has(OptionalProperty.class)) { PropertyNotFound propertyNotFound = errorCollector.get(0); delegate.propertyNotFound(propertyNotFound.target, propertyNotFound.property); } } finally { errorCollector.clear(); } }
@Override public void handle(PropertyMapping<T, ?, K> tkPropertyMapping) { if (tkPropertyMapping.getColumnDefinition().has(IgnoreRowIfNullProperty.class)) { mandatoryKeys.add(tkPropertyMapping.getColumnKey()); } } }).mandatoryKeys;
@Override public void handle(PropertyMapping<T, ?, K> tkPropertyMapping) { if (tkPropertyMapping.getColumnDefinition().has(IgnoreRowIfNullProperty.class)) { mandatoryKeys.add(tkPropertyMapping.getColumnKey()); } } }).mandatoryKeys;
private void handleSelfPropertyMetaInvalidation(MapperBuilderErrorHandler errorHandler) { List<K> invalidateKeys = new ArrayList<K>(); for(ListIterator<PropertyMapping<T, ?, K>> iterator = properties.listIterator(); iterator.hasNext();) { PropertyMapping<T, ?, K> propertyMapping = iterator.next(); if (propertyMapping != null && !propertyMapping.getPropertyMeta().isValid()) { iterator.set(null); if (!propertyMapping.getColumnDefinition().has(OptionalProperty.class)) { invalidateKeys.add(propertyMapping.getColumnKey()); } } } for(K k : invalidateKeys) { errorHandler.propertyNotFound(classMeta.getType(), k.getName()); } }
private static List<String> getPrimaryKeys(Connection connection, ResultSetMetaData resultSetMetaData, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider) throws SQLException { List<String> primaryKeys = new ArrayList<String>(); for(int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { JdbcColumnKey key = JdbcColumnKey.of(resultSetMetaData, i); if (columnDefinitionProvider.getColumnDefinition(key).has(KeyProperty.class)) { primaryKeys.add(key.getName()); } } if (!primaryKeys.isEmpty()) { return primaryKeys; } String catalogName = resultSetMetaData.getCatalogName(1); String schemaName = resultSetMetaData.getSchemaName(1); String tableName = resultSetMetaData.getTableName(1); try { ResultSet set = connection.getMetaData().getPrimaryKeys(catalogName, schemaName, tableName); try { while (set.next()) { primaryKeys.add(set.getString("COLUMN_NAME")); } } finally { set.close(); } } catch (SQLSyntaxErrorException e) { // ignore likely mysql view issues } return primaryKeys; }
private void handleSelfPropertyMetaInvalidation(MapperBuilderErrorHandler errorHandler) { List<K> invalidateKeys = new ArrayList<K>(); for(ListIterator<PropertyMapping<T, ?, K>> iterator = properties.listIterator(); iterator.hasNext();) { PropertyMapping<T, ?, K> propertyMapping = iterator.next(); if (propertyMapping != null && !propertyMapping.getPropertyMeta().isValid()) { iterator.set(null); if (!propertyMapping.getColumnDefinition().has(OptionalProperty.class)) { invalidateKeys.add(propertyMapping.getColumnKey()); } } } for(K k : invalidateKeys) { errorHandler.propertyNotFound(classMeta.getType(), k.getName()); } }
private static List<String> getPrimaryKeys(Connection connection, ResultSetMetaData resultSetMetaData, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider) throws SQLException { List<String> primaryKeys = new ArrayList<String>(); for(int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { JdbcColumnKey key = JdbcColumnKey.of(resultSetMetaData, i); if (columnDefinitionProvider.getColumnDefinition(key).has(KeyProperty.class)) { primaryKeys.add(key.getName()); } } if (!primaryKeys.isEmpty()) { return primaryKeys; } String catalogName = resultSetMetaData.getCatalogName(1); String schemaName = resultSetMetaData.getSchemaName(1); String tableName = resultSetMetaData.getTableName(1); try { ResultSet set = connection.getMetaData().getPrimaryKeys(catalogName, schemaName, tableName); try { while (set.next()) { primaryKeys.add(set.getString("COLUMN_NAME")); } } finally { set.close(); } } catch (SQLSyntaxErrorException e) { // ignore likely mysql view issues } return primaryKeys; }
private static int getParameterType(PropertyMapping<?, ?, JdbcColumnKey> pm) { Class<?> propertyType = TypeHelper.toClass(pm.getPropertyMeta().getPropertyType()); if (pm.getColumnDefinition().has(SqlTypeColumnProperty.class)) { return pm.getColumnDefinition().lookFor(SqlTypeColumnProperty.class).getSqlType(); } int t = StatementCreatorUtils.javaTypeToSqlParameterType(propertyType); if (t == SqlTypeValue.TYPE_UNKNOWN) { //IFJAVA8_START if (propertyType.equals(ZonedDateTime.class) || propertyType.equals(OffsetDateTime.class)) { return Types.TIMESTAMP_WITH_TIMEZONE; } if (propertyType.equals(Instant.class) || propertyType.equals(LocalDateTime.class)) { return Types.TIMESTAMP; } if (propertyType.equals(LocalDate.class)) { return Types.DATE; } if (propertyType.equals(LocalTime.class)) { return Types.TIME; } //IFJAVA8_END return JdbcColumnKey.UNDEFINED_TYPE; } return t; }
private static CrudMeta getCrudMeta(Connection connection, String table, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider, ResultSet resultSet, DatabaseMeta databaseMeta) throws SQLException { ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); ColumnMeta[] columnMetas = new ColumnMeta[resultSetMetaData.getColumnCount()]; List<String> primaryKeys = getPrimaryKeys(connection, resultSetMetaData, columnDefinitionProvider); int length = columnMetas.length; for(int i = 0; i < length; i++) { String columnName = resultSetMetaData.getColumnName(i + 1); ColumnDefinition<JdbcColumnKey,?> columnDefinition = columnDefinitionProvider.getColumnDefinition(JdbcColumnKey.of(resultSetMetaData, i + 1)); AutoGeneratedProperty autoGeneratedProperty = columnDefinition.lookFor(AutoGeneratedProperty.class); if (autoGeneratedProperty == null && resultSetMetaData.isAutoIncrement(i + 1) && ! columnDefinition.has(IgnoreAutoGeneratedProperty.class)) { autoGeneratedProperty = AutoGeneratedProperty.DEFAULT; } columnMetas[i] = new ColumnMeta( columnName, resultSetMetaData.getColumnType(i + 1), primaryKeys.contains(columnName), autoGeneratedProperty); } return new CrudMeta(databaseMeta, table, columnMetas); }
private static CrudMeta getCrudMeta(Connection connection, String table, ColumnDefinitionProvider<JdbcColumnKey> columnDefinitionProvider, ResultSet resultSet, DatabaseMeta databaseMeta) throws SQLException { ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); ColumnMeta[] columnMetas = new ColumnMeta[resultSetMetaData.getColumnCount()]; List<String> primaryKeys = getPrimaryKeys(connection, resultSetMetaData, columnDefinitionProvider); int length = columnMetas.length; for(int i = 0; i < length; i++) { String columnName = resultSetMetaData.getColumnName(i + 1); ColumnDefinition<JdbcColumnKey,?> columnDefinition = columnDefinitionProvider.getColumnDefinition(JdbcColumnKey.of(resultSetMetaData, i + 1)); AutoGeneratedProperty autoGeneratedProperty = columnDefinition.lookFor(AutoGeneratedProperty.class); if (autoGeneratedProperty == null && resultSetMetaData.isAutoIncrement(i + 1) && ! columnDefinition.has(IgnoreAutoGeneratedProperty.class)) { autoGeneratedProperty = AutoGeneratedProperty.DEFAULT; } columnMetas[i] = new ColumnMeta( columnName, resultSetMetaData.getColumnType(i + 1), primaryKeys.contains(columnName), autoGeneratedProperty); } return new CrudMeta(databaseMeta, table, columnMetas); }
@SuppressWarnings("unchecked") protected <P> FieldMapper<S, T> newFieldMapper(PropertyMapping<T, P, K> t) { ColumnDefinition<K, ?> columnDefinition = t.getColumnDefinition(); FieldMapper<S, T> fieldMapper = null; if (columnDefinition.has(FieldMapperProperty.class)) { fieldMapper = (FieldMapper<S, T>) columnDefinition.lookFor(FieldMapperProperty.class).getFieldMapper(); } if (fieldMapper == null) { fieldMapper = fieldMapperFactory.newFieldMapper(t, mappingContextFactoryBuilder, mapperConfig.mapperBuilderErrorHandler()); } return wrapFieldMapperWithErrorHandler(t.getColumnKey(), fieldMapper); }
@SuppressWarnings("unchecked") protected <P> FieldMapper<S, T> newFieldMapper(PropertyMapping<T, P, K> t) { ColumnDefinition<K, ?> columnDefinition = t.getColumnDefinition(); FieldMapper<S, T> fieldMapper = null; if (columnDefinition.has(FieldMapperProperty.class)) { fieldMapper = (FieldMapper<S, T>) columnDefinition.lookFor(FieldMapperProperty.class).getFieldMapper(); } if (fieldMapper == null) { fieldMapper = fieldMapperFactory.newFieldMapper(t, mappingContextFactoryBuilder, mapperConfig.mapperBuilderErrorHandler()); } return wrapFieldMapperWithErrorHandler(t.getColumnKey(), fieldMapper); }
if (!columnDefinition.has(OptionalProperty.class)) { AccessorNotFound accessorNotFound = selectAccessotNotFound(accessorNotFounds); if (accessorNotFound == null) {
if (!columnDefinition.has(OptionalProperty.class)) { AccessorNotFound accessorNotFound = selectAccessotNotFound(accessorNotFounds); if (accessorNotFound == null) {
if (TypeHelper.isPrimitive(type) && !columnDefinition.has(FormatProperty.class)) { if (getter instanceof BooleanGetter) { return new BooleanConstantTargetFieldMapper<S, Appendable>((BooleanGetter<? super S>) getter, new BooleanAppendableSetter(cellWriter)); if (TypeHelper.isEnum(type) && columnDefinition.has(EnumOrdinalFormatProperty.class)) { setter = (ContextualSetter<Appendable, ? super P>) new EnumOrdinalAppendableSetter(cellWriter); if (columnDefinition.has(FormatProperty.class)) { format = columnDefinition.lookFor(FormatProperty.class).format(); } else if (TypeHelper.areEquals(type, Date.class)) {