@@ -0,0 +1,1254 @@
+package org.javers.repository.sql.session;%0A%0Aimport org.polyjdbc.core.PolyJDBC;%0Aimport org.polyjdbc.core.query.SelectQuery;%0A%0Aimport java.math.BigDecimal;%0Aimport java.util.List;%0Aimport java.util.Optional;%0A%0A/**%0A * @author bartosz walacik%0A */%0Apublic class PolyUtil %7B%0A    public static List%3CLong%3E queryForLongList(SelectQuery query, PolyJDBC poly)%7B%0A        return poly.queryRunner().queryList(query, resultSet -%3E resultSet.getLong(1));%0A    %7D%0A%0A    static List%3CBigDecimal%3E queryForBigDecimalList(SelectQuery query, PolyJDBC poly)%7B%0A        return poly.queryRunner().queryList(query, resultSet -%3E resultSet.getBigDecimal(1));%0A    %7D%0A%0A    public static Optional%3CBigDecimal%3E queryForOptionalBigDecimal(SelectQuery query, PolyJDBC poly)%7B%0A        List%3CBigDecimal%3E result = queryForBigDecimalList(query, poly);%0A%0A        if (result.isEmpty() %7C%7C (result.size() == 1 && result.get(0) == null))%7B%0A            return Optional.empty();%0A        %7D%0A%0A        return Optional.of(result.get(0));%0A    %7D%0A%0A    public static Optional%3CLong%3E queryForOptionalLong(SelectQuery query, PolyJDBC poly)%7B%0A        List%3CLong%3E result = queryForLongList(query, poly);%0A%0A        if (result.isEmpty())%7B%0A            return Optional.empty();%0A        %7D%0A%0A        return Optional.of(result.get(0));%0A    %7D%0A%7D%0A

work in progress