use of org.jkiss.dbeaver.model.struct.DBSTypedObjectEx in project dbeaver by serge-rider.
the class ArrayAttributeTransformer method transformAttribute.
@Override
public void transformAttribute(@NotNull DBCSession session, @NotNull DBDAttributeBinding attribute, @NotNull List<Object[]> rows, @NotNull Map<String, String> options) throws DBException {
DBSDataType collectionType;
if (attribute.getAttribute() instanceof DBSTypedObjectEx) {
collectionType = ((DBSTypedObjectEx) attribute.getAttribute()).getDataType();
} else {
collectionType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), attribute.getTypeName());
}
if (collectionType != null) {
DBSDataType componentType = collectionType.getComponentType(session.getProgressMonitor());
if (componentType instanceof DBSEntity) {
ComplexTypeAttributeTransformer.createNestedTypeBindings(session, attribute, rows, (DBSEntity) componentType);
return;
}
}
// No component type found.
// Array items should be resolved in a lazy mode
MapAttributeTransformer.resolveMapsFromData(session, attribute, rows);
}
use of org.jkiss.dbeaver.model.struct.DBSTypedObjectEx in project dbeaver by serge-rider.
the class JDBCCollection method makeCollectionFromArray.
/////////////////////////////////////////////////////////////////////////////////////
// Utilities
/////////////////////////////////////////////////////////////////////////////////////
@NotNull
public static JDBCCollection makeCollectionFromArray(@NotNull JDBCSession session, @NotNull DBSTypedObject column, Array array) throws DBCException {
DBRProgressMonitor monitor = session.getProgressMonitor();
DBSDataType elementType = null;
if (column instanceof DBSTypedObjectEx) {
DBSDataType arrayType = ((DBSTypedObjectEx) column).getDataType();
if (arrayType != null) {
elementType = arrayType.getComponentType(monitor);
}
}
if (elementType == null) {
try {
if (array == null) {
String arrayTypeName = column.getTypeName();
DBSDataType arrayType = session.getDataSource().resolveDataType(monitor, arrayTypeName);
if (arrayType != null) {
elementType = arrayType.getComponentType(monitor);
}
} else {
String baseTypeName = array.getBaseTypeName();
elementType = session.getDataSource().resolveDataType(monitor, baseTypeName);
}
} catch (Exception e) {
throw new DBCException("Error resolving data type", e);
}
}
try {
if (elementType == null) {
if (array == null) {
throw new DBCException("Can't resolve NULL array data type");
}
try {
return makeCollectionFromResultSet(session, array, null);
} catch (SQLException e) {
//$NON-NLS-1$
throw new DBCException(e, session.getDataSource());
}
}
try {
return makeCollectionFromArray(session, array, elementType);
} catch (SQLException e) {
if (array == null) {
//$NON-NLS-1$
throw new DBCException(e, session.getDataSource());
}
try {
return makeCollectionFromResultSet(session, array, elementType);
} catch (SQLException e1) {
//$NON-NLS-1$
throw new DBCException(e1, session.getDataSource());
}
}
} catch (DBException e) {
//$NON-NLS-1$
throw new DBCException("Can't extract array data from JDBC array", e);
}
}
Aggregations