@Override public Struct getStruct() { final Object o = super.getObject(); if (o == null) { return null; } else if (o instanceof List) { return new StructImpl((List) o); } else { final List<Object> list = new ArrayList<>(); for (Accessor fieldAccessor : fieldAccessors) { try { list.add(fieldAccessor.getObject()); } catch (SQLException e) { throw new RuntimeException(e); } } return new StructImpl(list); } } }
@Override public Struct getStruct() throws SQLException { final Object o = super.getObject(); if (o == null) { return null; } else if (o instanceof StructImpl) { return (StructImpl) o; } else if (o instanceof List) { return new StructImpl((List) o); } else { final List<Object> list = new ArrayList<>(); for (Accessor fieldAccessor : fieldAccessors) { list.add(fieldAccessor.getObject()); } return new StructImpl(list); } } }
@Override public Struct getStruct() throws SQLException { final Object o = super.getObject(); if (o == null) { return null; } else if (o instanceof StructImpl) { return (StructImpl) o; } else if (o instanceof List) { return new StructImpl((List) o); } else { final List<Object> list = new ArrayList<>(); for (Accessor fieldAccessor : fieldAccessors) { list.add(fieldAccessor.getObject()); } return new StructImpl(list); } } }
@Override public void testGetStruct(ResultSet resultSet) throws SQLException { Struct expectedStruct = new StructImpl(Arrays.asList(42, false)); assertEquals(expectedStruct, g.getStruct(resultSet)); } }
@Override public void testGetStruct(ResultSet resultSet) throws SQLException { Struct expectedStruct = new StructImpl(Arrays.asList(42, false)); assertEquals(expectedStruct, g.getStruct(resultSet)); } }
StructType structType = ColumnMetaData.struct(Arrays.asList(intMetaData, stringMetaData)); Struct struct1 = new StructImpl(Arrays.<Object>asList(1, "one")); Struct struct2 = new StructImpl(Arrays.<Object>asList(2, "two")); Struct struct3 = new StructImpl(Arrays.<Object>asList(3)); Struct struct4 = new StructImpl(Arrays.<Object>asList(4, "four", "ignored")); ColumnMetaData structMetaData = MetaImpl.columnMetaData("MY_STRUCT", 1, structType, false); List<List<Object>> rows = Arrays.asList(Collections.<Object>singletonList(struct1),
StructType structType = ColumnMetaData.struct(Arrays.asList(intMetaData, stringMetaData)); Struct struct1 = new StructImpl(Arrays.<Object>asList(1, "one")); Struct struct2 = new StructImpl(Arrays.<Object>asList(2, "two")); Struct struct3 = new StructImpl(Arrays.<Object>asList(3)); Struct struct4 = new StructImpl(Arrays.<Object>asList(4, "four", "ignored")); ColumnMetaData structMetaData = MetaImpl.columnMetaData("MY_STRUCT", 1, structType, false); List<List<Object>> rows = Arrays.asList(Collections.<Object>singletonList(struct1),
StructType structType = ColumnMetaData.struct(Arrays.asList(intMetaData, stringMetaData)); Struct struct1 = new StructImpl(Arrays.<Object>asList(1, "one")); Struct struct2 = new StructImpl(Arrays.<Object>asList(2, "two")); Struct struct3 = new StructImpl(Arrays.<Object>asList(3)); Struct struct4 = new StructImpl(Arrays.<Object>asList(4, "four")); ArrayType arrayType = ColumnMetaData.array(structType, "OBJECT", Rep.STRUCT); ColumnMetaData arrayMetaData = MetaImpl.columnMetaData("MY_ARRAY", 1, arrayType, false);
StructType structType = ColumnMetaData.struct(Arrays.asList(intMetaData, stringMetaData)); Struct struct1 = new StructImpl(Arrays.<Object>asList(1, "one")); Struct struct2 = new StructImpl(Arrays.<Object>asList(2, "two")); Struct struct3 = new StructImpl(Arrays.<Object>asList(3)); Struct struct4 = new StructImpl(Arrays.<Object>asList(4, "four")); ArrayType arrayType = ColumnMetaData.array(structType, "OBJECT", Rep.STRUCT); ColumnMetaData arrayMetaData = MetaImpl.columnMetaData("MY_ARRAY", 1, arrayType, false);
new Timestamp(1476130718123L), Arrays.asList(1, 2, 3), new StructImpl(Arrays.asList(42, false)) });
new Timestamp(1476130718123L), Arrays.asList(1, 2, 3), new StructImpl(Arrays.asList(42, false)) });