use of org.jkiss.dbeaver.model.impl.jdbc.JDBCStructImpl in project dbeaver by serge-rider.
the class JDBCStructValueHandler method getValueFromObject.
@Override
public Object getValueFromObject(@NotNull DBCSession session, @NotNull DBSTypedObject type, Object object, boolean copy, boolean validateValue) throws DBCException {
if (object instanceof JDBCComposite) {
return copy ? ((JDBCComposite) object).cloneValue(session.getProgressMonitor()) : object;
}
String typeName;
try {
if (object instanceof Struct) {
typeName = ((Struct) object).getSQLTypeName();
} else {
typeName = type.getTypeName();
}
} catch (SQLException e) {
throw new DBCException(e, session.getExecutionContext());
}
DBSDataType dataType = null;
try {
dataType = DBUtils.resolveDataType(session.getProgressMonitor(), session.getDataSource(), typeName);
} catch (DBException e) {
log.debug("Error resolving data type '" + typeName + "'", e);
}
if (dataType == null) {
if (object instanceof Struct) {
return new JDBCCompositeDynamic(session, (Struct) object, null);
} else {
return new JDBCCompositeUnknown(session, object);
}
}
if (object == null) {
return new JDBCCompositeStatic(session, dataType, new JDBCStructImpl(dataType.getTypeName(), null, ""));
} else if (object instanceof Struct) {
return new JDBCCompositeStatic(session, dataType, (Struct) object);
} else {
return new JDBCCompositeUnknown(session, object);
}
}
Aggregations