コード例 #1
0
ファイル: FieldTypeHelper.java プロジェクト: Arbonaut/jOOQ
  /**
   * Create a UDT record from a PGobject
   *
   * <p>Unfortunately, this feature is very poorly documented and true UDT support by the PostGreSQL
   * JDBC driver has been postponed for a long time.
   *
   * @param object An object of type PGobject. The actual argument type cannot be expressed in the
   *     method signature, as no explicit dependency to postgres logic is desired
   * @return The converted {@link UDTRecord}
   */
  private static UDTRecord<?> pgNewUDTRecord(Class<?> type, Object object) throws SQLException {
    if (object == null) {
      return null;
    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    UDTRecord<?> record = (UDTRecord<?>) Util.newRecord((Class) type);
    List<String> values = PostgresUtils.toPGObject(object.toString());

    List<Field<?>> fields = record.getFields();
    for (int i = 0; i < fields.size(); i++) {
      pgSetValue(record, fields.get(i), values.get(i));
    }

    return record;
  }