Example usage for javax.persistence Tuple getElements

List of usage examples for javax.persistence Tuple getElements

Introduction

In this page you can find the example usage for javax.persistence Tuple getElements.

Prototype

List<TupleElement<?>> getElements();

Source Link

Document

Return the tuple elements.

Usage

From source file:com.evanzeimet.queryinfo.jpa.result.AbstractTupleToPojoQueryInfoResultConverter.java

@Override
public List<QueryInfoResultType> convert(List<Tuple> tuples) throws QueryInfoException {
    List<QueryInfoResultType> result;

    if (tuples.isEmpty()) {
        result = Collections.emptyList();
    } else {/*from  w  ww  .  ja  v  a  2s .  co  m*/
        Tuple peek = tuples.get(0);
        List<TupleElement<?>> tupleElements = peek.getElements();

        try {
            Map<String, MethodHandle> methodHandles = mapElementMethodHandles(tupleElements);
            result = convertTuples(methodHandles, tuples);
        } catch (Throwable e) {
            throw new QueryInfoException(e);
        }
    }

    return result;
}

From source file:org.fornax.cartridges.sculptor.framework.accessimpl.jpa2.JpaHelper.java

/**
 *
 * @param <T>/*from w w  w  . j  a  v a2 s  .com*/
 * @param tuple
 * @param object
 * @return
 */
public static <T> T mapTupleToObject(Tuple tuple, T object)
        throws IllegalAccessException, InvocationTargetException {
    assert tuple != null;
    assert object != null;
    try {
        for (TupleElement<?> element : tuple.getElements()) {
            if (element.getAlias() != null) {
                BeanUtils.setProperty(object, element.getAlias(), tuple.get(element.getAlias()));
            }
        }
        return object;
    } catch (Exception e) {
        log.error("mapTupleToObject not successful", e);
        throw new QueryConfigException("mapTupleToObject not successful");
    }
}