Package fi.evident.dalesbred.instantiation

Examples of fi.evident.dalesbred.instantiation.NamedTypeList


    @NotNull
    @Override
    public Map<K, V> process(@NotNull ResultSet resultSet) throws SQLException {
        Map<K,V> result = new LinkedHashMap<K,V>();

        NamedTypeList types = ResultSetUtils.getTypes(resultSet.getMetaData());
        if (types.size() != 2)
            throw new UnexpectedResultException("Expected ResultSet with 2 columns, but got " + types.size() + " columns.");

        TypeConversion<Object, K> keyConversion = getConversion(types.getType(0), keyType);
        TypeConversion<Object, V> valueConversion = getConversion(types.getType(1), valueType);

        while (resultSet.next()) {
            K key = convert(keyConversion, resultSet.getObject(1));
            V value = convert(valueConversion, resultSet.getObject(2));
            //noinspection ConstantConditions
View Full Code Here


    }

    @NotNull
    @Override
    public List<T> process(@NotNull ResultSet resultSet) throws SQLException {
        NamedTypeList types = ResultSetUtils.getTypes(resultSet.getMetaData());
        Instantiator<T> ctor = instantiatorRegistry.findInstantiator(cl, types);
        boolean allowNulls = !cl.isPrimitive();

        ArrayList<T> result = new ArrayList<T>();

        // For performance reasons we reuse the same arguments-array and InstantiatorArguments-object for all rows.
        // This should be fine as long as the instantiators don't hang on to their arguments for too long.
        Object[] arguments = new Object[types.size()];
        InstantiatorArguments instantiatorArguments = new InstantiatorArguments(types, Arrays.asList(arguments));

        while (resultSet.next()) {
            for (int i = 0; i < arguments.length; i++)
                arguments[i] = resultSet.getObject(i+1);
View Full Code Here

TOP

Related Classes of fi.evident.dalesbred.instantiation.NamedTypeList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.