Example usage for java.lang Number longValue

List of usage examples for java.lang Number longValue

Introduction

In this page you can find the example usage for java.lang Number longValue.

Prototype

public abstract long longValue();

Source Link

Document

Returns the value of the specified number as a long .

Usage

From source file:com.tesora.dve.sql.parser.TranslatorUtils.java

public TableModifier buildAutoincTableModifier(ExpressionNode litval) {
    LiteralExpression lit = (LiteralExpression) litval;
    Object value = lit.getValue(pc.getValues());
    if (value instanceof Number) {
        Number n = (Number) value;
        return new AutoincTableModifier(n.longValue());
    }//from w  w w.jav a  2  s . c o m
    throw new SchemaException(Pass.SECOND, "Unknown autoinc value kind: " + value.getClass().getSimpleName());
}

From source file:org.objectstyle.cayenne.dataview.DataTypeSpec.java

public Object fromDataType(Class untypedValueClass, DataTypeEnum dataType, Object typedValue) {
    if (typedValue == null)
        return null;
    Class dataTypeClass = getJavaClass(dataType);
    //    Validate.isTrue(typedValue.getClass().equals(dataTypeClass));

    if (untypedValueClass == null)
        return typedValue;

    if (ClassUtils.isAssignable(dataTypeClass, untypedValueClass))
        return typedValue;

    String strTypedValue = null;//www.ja v  a2s .com
    boolean isStringTypedValue;
    Number numTypedValue = null;
    boolean isNumberTypedValue;
    Boolean boolTypedValue = null;
    boolean isBooleanTypedValue;
    Date dateTypedValue = null;
    boolean isDateTypedValue;

    if (isStringTypedValue = typedValue instanceof String)
        strTypedValue = (String) typedValue;
    if (isNumberTypedValue = typedValue instanceof Number)
        numTypedValue = (Number) typedValue;
    if (isBooleanTypedValue = typedValue instanceof Boolean)
        boolTypedValue = (Boolean) typedValue;
    if (isDateTypedValue = typedValue instanceof Date)
        dateTypedValue = (Date) typedValue;

    Object v = null;
    if (String.class.equals(untypedValueClass)) {
        v = ObjectUtils.toString(typedValue);
    } else if (BigDecimal.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = NumberUtils.createBigDecimal(strTypedValue);
        else if (isNumberTypedValue)
            v = new BigDecimal(numTypedValue.doubleValue());
        else if (isBooleanTypedValue)
            v = new BigDecimal(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        else if (isDateTypedValue)
            v = new BigDecimal(dateTypedValue.getTime());
    } else if (Boolean.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = BooleanUtils.toBooleanObject(strTypedValue);
        else if (isNumberTypedValue)
            v = BooleanUtils.toBooleanObject(numTypedValue.intValue());
        else if (isDateTypedValue)
            v = BooleanUtils.toBooleanObject((int) dateTypedValue.getTime());
    } else if (Byte.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = Byte.valueOf(strTypedValue);
        else if (isNumberTypedValue)
            v = new Byte(numTypedValue.byteValue());
        else if (isBooleanTypedValue)
            v = new Byte((byte) BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        else if (isDateTypedValue)
            v = new Byte((byte) dateTypedValue.getTime());
    } else if (byte[].class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = strTypedValue.getBytes();
    } else if (Double.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = NumberUtils.createDouble(strTypedValue);
        else if (isNumberTypedValue)
            v = new Double(numTypedValue.doubleValue());
        else if (isBooleanTypedValue)
            v = new Double(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        else if (isDateTypedValue)
            v = new Double(dateTypedValue.getTime());
    } else if (Float.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = NumberUtils.createFloat(strTypedValue);
        else if (isNumberTypedValue)
            v = new Float(numTypedValue.floatValue());
        else if (isBooleanTypedValue)
            v = new Float(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        else if (isDateTypedValue)
            v = new Float(dateTypedValue.getTime());
    } else if (Integer.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = NumberUtils.createInteger(strTypedValue);
        else if (isNumberTypedValue)
            v = new Integer(numTypedValue.intValue());
        else if (isBooleanTypedValue)
            v = BooleanUtils.toIntegerObject(boolTypedValue.booleanValue());
        else if (isDateTypedValue)
            v = new Integer((int) dateTypedValue.getTime());
    } else if (Long.class.equals(untypedValueClass)) {
        if (isStringTypedValue)
            v = NumberUtils.createLong(strTypedValue);
        else if (isNumberTypedValue)
            v = new Long(numTypedValue.longValue());
        else if (isBooleanTypedValue)
            v = new Long(BooleanUtils.toInteger(boolTypedValue.booleanValue()));
        else if (isDateTypedValue)
            v = new Long(dateTypedValue.getTime());
    } else if (java.sql.Date.class.equals(untypedValueClass)) {
        if (isNumberTypedValue)
            v = new java.sql.Date(numTypedValue.longValue());
        else if (isDateTypedValue)
            v = new java.sql.Date(dateTypedValue.getTime());
    } else if (java.sql.Time.class.equals(untypedValueClass)) {
        if (isNumberTypedValue)
            v = new java.sql.Time(numTypedValue.longValue());
        else if (isDateTypedValue)
            v = new java.sql.Time(dateTypedValue.getTime());
    } else if (java.sql.Timestamp.class.equals(untypedValueClass)) {
        if (isNumberTypedValue)
            v = new java.sql.Timestamp(numTypedValue.longValue());
        else if (isDateTypedValue)
            v = new java.sql.Timestamp(dateTypedValue.getTime());
    } else if (Date.class.equals(untypedValueClass)) {
        if (isNumberTypedValue)
            v = new Date(numTypedValue.longValue());
    }
    return v;
}

From source file:hudson.plugins.project_inheritance.projects.InheritanceProject.java

/**
 * This method tries to fetch the version number from the current
 * Stapler request./*  w  ww  .j av  a 2s. c o  m*/
 * <p>
 * Do note that this only works in threads started by a Web-/GUI-request.
 * It will not work if a call is triggered by the CLI, during the
 * actual execution of a build or when Jenkins is querying values
 * internally.
 * 
 * @return the version desired by the user; or null if not a request
 */
private Long getUserDesiredVersionFromRequest() {
    //Checking if we were invoked through an HTTP URL request
    StaplerRequest req = Stapler.getCurrentRequest();
    if (req == null) {
        return null;
    }

    //Checking if there's a specific "versions" attribute associated with
    //the current request, and is a Map of Strings to Long values
    Object verObj = req.getAttribute("versions");
    if (verObj != null && verObj instanceof Map) {
        Map verMap = (Map) verObj;
        try {
            Object ver = verMap.get(this.getName());
            if (ver != null && ver instanceof Number) {
                return ((Number) ver).longValue();
            }
        } catch (ClassCastException ex) {
            log.warning("ClassCaseException when attempting to decode 'versions' attribute of HTTP-Request");
        } catch (NullPointerException ex) {
            log.warning("NullPointerException when attempting to decode 'versions' attribute of HTTP-Request");
        }
    }

    //If that did not exist, we try for the broader "timestamp" attribute
    Object tsObj = req.getAttribute("vTimestamp");
    if (tsObj != null && tsObj instanceof Number) {
        Number ts = (Number) tsObj;
        Version v = this.versionStore.getNearestTo(ts.longValue());
        if (v != null) {
            return v.id;
        }
    }

    //Now that we've exhausted the attributes, we need to check the raw
    //URL parameters, which are of course MUCH more brittle

    String verParm = req.getParameter("versions");
    if (verParm != null && !verParm.isEmpty()) {
        Map<String, Long> verMap = InheritanceParametersDefinitionProperty.decodeVersioningMap(verParm);
        if (!verMap.isEmpty()) {
            InheritanceProject.setVersioningMap(verMap);
        }
        //And checking if it contained a matching for the current project
        Long version = verMap.get(this.getName());
        if (version != null) {
            return version;
        }
    }

    //If that failed, we try to get the "timestamp" attribute
    String tsParm = req.getParameter("timestamp");
    if (tsParm != null && !tsParm.isEmpty()) {
        //Trying to parse as a number
        try {
            Long ts = Long.valueOf(tsParm, 10);
            if (ts != null && ts >= 0) {
                //Saving it, to not re-decode it again
                req.setAttribute("vTimestamp", ts);
                Version v = this.versionStore.getNearestTo(ts.longValue());
                if (v != null) {
                    return v.id;
                }
            }
        } catch (NumberFormatException ex) {
            log.warning(
                    "NumberFormatException when attempting to decode 'timestamp' attribute of HTTP-Request");
        }
    }

    /* If that also failed, we try to decode the simple "version" parameter
     * Since this is always just defined for ONE particular project, we
     * need to grab the stable version closest to the timestamp of
     * the specified version when dealing with other projects.
     */

    verParm = req.getParameter("version");
    if (verParm != null) {
        //Fetching the project associated with that request; if any
        InheritanceProject ip = this.getProjectFromRequest(req);
        if (ip != null) {
            try {
                Long vNum = Long.valueOf(verParm, 10);
                if (this == ip) {
                    return vNum;
                }
                //Fetching the timestamp of that version
                Version v = ip.versionStore.getVersion(vNum);
                if (v != null) {
                    long ts = v.timestamp;
                    //Fetching the best matching version to that ts
                    Version near = this.versionStore.getNearestTo(ts);
                    if (near != null) {
                        return near.id;
                    }
                }
            } catch (NumberFormatException ex) {
                log.warning(
                        "NumberFormatException when attempting to decode 'version' attribute of HTTP-Request");
            }
        }
    }
    //If we reach this spot; no version was defined anywhere
    return null;
    //return this.getStableVersion();
}

From source file:org.opendaylight.vtn.manager.it.northbound.VtnNorthboundIT.java

/**
 * Convert the given numbers into a {@link JSONObject} instance which
 * represents a {@code XmlLongIntegerList} instance.
 *
 * @param numbers  A collection of numbers.
 * @return  A {@link JSONObject} instance.
 * @throws JSONException  An error occurred.
 *//* w w w  .  j av a2  s.  co  m*/
private JSONObject toXmlLongIntegerList(Collection<? extends Number> numbers) throws JSONException {
    JSONArray array = new JSONArray();
    for (Number num : numbers) {
        array.put(new JSONObject().put("value", num.longValue()));
    }

    return new JSONObject().put("integer", array);
}

From source file:cc.aileron.dao.db.G2DaoImpl.java

@Override
public <C> G2DaoWhere<T> where(final C condition, final Class<C> wtype) {
    return new G2DaoWhere<T>() {
        @Override//w w w .  j a  v a2 s.  c o  m
        public int delete() {
            final Number result = G2DaoImpl.this.execute(DELETE, null, condition, wtype);
            return result != null ? result.intValue() : 0;
        }

        @Override
        public void execute() {
            G2DaoImpl.this.execute(EXECUTE, null, condition, wtype);
        }

        @Override
        public G2DaoFinder<T> find() {
            final PojoAccessorManager manager = G2DaoImpl.this.manager;
            final Provider<PojoAccessor<T>> provider = G2DaoImpl.this.provider;
            return new G2DaoFinder<T>() {
                @Override
                public void bind(final T object) {
                    if (object == null) {
                        throw new IllegalArgumentException("bindable object is null");
                    }
                    final PojoAccessor<T> accessor = manager.from(object);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            if (!resultSet.next()) {
                                return;
                            }
                            bind(accessor, columnNames, resultSet);
                        }
                    });
                }

                @Override
                public int count() {
                    final ObjectContainer<Integer> c = new ObjectContainer<Integer>(0);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException {
                            if (resultSet.next()) {
                                c.value = resultSet.getInt(1);
                            }
                        }

                        @Override
                        public G2DaoMethod method() {
                            return G2DaoMethod.COUNT;
                        }
                    });
                    return c.value;
                }

                @Override
                public void each(final Procedure<T> procedure) {
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            while (resultSet.next()) {
                                final PojoAccessor<T> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                final T target = accessor.toTarget();
                                procedure.call(target);
                            }
                        }

                        @Override
                        public boolean isEach() {
                            return true;
                        }
                    });
                }

                @Override
                public void each(final Procedure<T> procedure, final G2DaoPaging paging) {
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            final int offset = paging.offset();
                            final int size = paging.limit();

                            int i = 0;
                            boolean isNext = offset == 0 ? resultSet.next() : resultSet.absolute(offset);
                            while (isNext) {
                                i += 1;

                                if (size < i) {
                                    resultSet.close();
                                    break;
                                }

                                final PojoAccessor<T> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                final T target = accessor.toTarget();
                                procedure.call(target);

                                isNext = resultSet.next();
                            }
                        }
                    });
                }

                @Override
                public boolean exist() {
                    final ObjectContainer<Boolean> c = new ObjectContainer<Boolean>(false);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException {
                            c.value = resultSet.next();
                        }
                    });
                    return c.value;
                }

                @Override
                public List<T> list() {
                    final ObjectContainer<List<T>> c = new ObjectContainer<List<T>>(new ArrayList<T>(50));
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            while (resultSet.next()) {
                                final PojoAccessor<T> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                c.value.add(accessor.toTarget());
                            }
                        }
                    });
                    return c.value;
                }

                @Override
                public List<T> list(final G2DaoPaging paging) {
                    final ObjectContainer<List<T>> c = new ObjectContainer<List<T>>(new ArrayList<T>(50));
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            final int offset = paging.offset();
                            final int size = paging.limit();

                            int i = 0;
                            boolean isNext = offset == 0 ? resultSet.next() : resultSet.absolute(offset);

                            while (isNext) {
                                i += 1;

                                if (size < i) {
                                    resultSet.close();
                                    break;
                                }

                                final PojoAccessor<T> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                c.value.add(accessor.toTarget());

                                isNext = resultSet.next();
                            }
                        }
                    });
                    return c.value;
                }

                @Override
                public T one() {
                    final String key;
                    if (isCacheable) {
                        final StringBuilder buff = new StringBuilder();

                        for (final Method method : (wtype != null ? wtype
                                : condition.getClass().getInterfaces()[0]).getDeclaredMethods()) {
                            try {
                                final Object v = method.invoke(condition);
                                buff.append(v).append('\0');
                            } catch (final IllegalArgumentException e) {
                                throw new Error(e);
                            } catch (final IllegalAccessException e) {
                                throw new Error(e);
                            } catch (final InvocationTargetException e) {
                                throw new Error(e);
                            }
                        }

                        key = buff.toString();
                        final T val = Cast.<T>cast(cache.get(key));
                        if (val != null) {
                            return val;
                        }
                    } else {
                        key = null;
                    }

                    final ObjectContainer<T> c = new ObjectContainer<T>();
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final PojoAccessor<T> accessor = provider.get();
                            final List<String> columnNames = getColumnNames(resultSet);
                            if (!resultSet.next()) {
                                return;
                            }
                            bind(accessor, columnNames, resultSet);
                            c.value = accessor.toTarget();
                        }
                    });
                    if (isCacheable) {
                        cache.put(key, c.value);
                    }
                    return c.value;
                }

            };
        }

        @Override
        public <R> G2DaoFinder<R> find(final Factory<R, ? super T> factory) {
            final PojoAccessorManager manager = G2DaoImpl.this.manager;
            final Provider<PojoAccessor<R>> provider = new Provider<PojoAccessor<R>>() {
                @Override
                public PojoAccessor<R> get() {
                    return manager.from(factory.get(G2DaoImpl.this.provider.get().toTarget()));
                }
            };
            return new G2DaoFinder<R>() {
                @Override
                public void bind(final R object) {
                    if (object == null) {
                        throw new IllegalArgumentException("bindable object is null");
                    }
                    final PojoAccessor<R> accessor = manager.from(object);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            if (!resultSet.next()) {
                                return;
                            }
                            bind(accessor, columnNames, resultSet);
                        }
                    });
                }

                @Override
                public int count() {
                    final ObjectContainer<Integer> c = new ObjectContainer<Integer>(0);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException {
                            if (resultSet.next()) {
                                c.value = resultSet.getInt(1);
                            }
                        }

                        @Override
                        public G2DaoMethod method() {
                            return G2DaoMethod.COUNT;
                        }
                    });
                    return c.value;
                }

                @Override
                public void each(final Procedure<R> procedure) {
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            while (resultSet.next()) {
                                final PojoAccessor<R> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                final R target = accessor.toTarget();
                                procedure.call(target);
                            }
                        }
                    });
                }

                @Override
                public void each(final Procedure<R> procedure, final G2DaoPaging paging) {
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            final int offset = paging.offset();
                            final int size = paging.limit();

                            int i = 0;
                            boolean isNext = offset == 0 ? resultSet.next() : resultSet.absolute(offset);
                            while (isNext) {
                                i += 1;

                                if (size < i) {
                                    resultSet.close();
                                    break;
                                }

                                final PojoAccessor<R> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                final R target = accessor.toTarget();
                                procedure.call(target);

                                isNext = resultSet.next();
                            }
                        }
                    });
                }

                @Override
                public boolean exist() {
                    final ObjectContainer<Boolean> c = new ObjectContainer<Boolean>(false);
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException {
                            c.value = resultSet.next();
                        }
                    });
                    return c.value;
                }

                @Override
                public List<R> list() {
                    final ObjectContainer<List<R>> c = new ObjectContainer<List<R>>(new ArrayList<R>(50));
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            while (resultSet.next()) {
                                final PojoAccessor<R> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                c.value.add(accessor.toTarget());
                            }
                        }
                    });
                    return c.value;
                }

                @Override
                public List<R> list(final G2DaoPaging paging) {
                    final ObjectContainer<List<R>> c = new ObjectContainer<List<R>>(new ArrayList<R>(50));
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final List<String> columnNames = getColumnNames(resultSet);
                            final int offset = paging.offset();
                            final int size = paging.limit();

                            int i = 0;
                            boolean isNext = offset == 0 ? resultSet.next() : resultSet.absolute(offset);

                            while (isNext) {
                                i += 1;

                                if (size < i) {
                                    resultSet.close();
                                    break;
                                }

                                final PojoAccessor<R> accessor = provider.get();
                                bind(accessor, columnNames, resultSet);
                                c.value.add(accessor.toTarget());

                                isNext = resultSet.next();
                            }
                        }
                    });
                    return c.value;
                }

                @Override
                public R one() {
                    final String key;
                    if (isCacheable) {
                        final StringBuilder buff = new StringBuilder();
                        for (final Method method : (wtype != null ? wtype
                                : condition.getClass().getInterfaces()[0]).getDeclaredMethods()) {
                            try {
                                buff.append(method.invoke(condition).toString()).append('\0');
                            } catch (final IllegalArgumentException e) {
                                throw new Error(e);
                            } catch (final IllegalAccessException e) {
                                throw new Error(e);
                            } catch (final InvocationTargetException e) {
                                throw new Error(e);
                            }
                        }
                        key = buff.toString();
                        final R val = Cast.<R>cast(cache.get(key));
                        if (val != null) {
                            return val;
                        }
                    } else {
                        key = null;
                    }

                    final ObjectContainer<R> c = new ObjectContainer<R>();
                    find(wtype, condition, new G2DaoResultHandler() {
                        @Override
                        public void execute(final ResultSet resultSet) throws SQLException,
                                PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException {
                            final PojoAccessor<R> accessor = provider.get();
                            final List<String> columnNames = getColumnNames(resultSet);
                            if (!resultSet.next()) {
                                return;
                            }
                            bind(accessor, columnNames, resultSet);
                            c.value = accessor.toTarget();
                        }
                    });
                    if (isCacheable) {
                        cache.put(key, c.value);
                    }
                    return c.value;
                }

            };
        }

        @Override
        public long insert(final T value) {
            final Number result = G2DaoImpl.this.execute(INSERT, value, condition, wtype);
            return result != null ? result.longValue() : 0;
        }

        @Override
        public int update(final T value) {
            final Number result = G2DaoImpl.this.execute(UPDATE, value, condition, wtype);
            return result != null ? result.intValue() : 0;
        }

        /**
         * @param invoker
         * @param condition
         */
        void find(final Class<?> wtype, final Object condition, final G2DaoResultHandler invoker) {
            if (condition == null) {
                return;
            }
            final Connection connection = transactionManager.get();
            try {
                executor.execute(transactionManager.db(), connection, wtype, condition, invoker);
            } catch (final Throwable e) {
                throw new Error("G2Dao [" + type.getName() + "] find by "
                        + (condition == G2DaoNoCondition.NO_CONDITION ? "all" : sqlName.get(condition, wtype)),
                        e);
            } finally {
                transactionManager.close(connection);
            }
        }
    };
}