List of usage examples for javax.persistence TupleElement getAlias
String getAlias();
From source file:com.evanzeimet.queryinfo.jpa.result.AbstractTupleToPojoQueryInfoResultConverter.java
protected MethodHandle getMethodHandleForElement(TupleElement<?> element) throws QueryInfoException { String elementAlias = element.getAlias(); String memberName = attributeUtils.convertAttributeNameToMemberName(elementAlias); Class<?> elementJavaType = element.getJavaType(); MethodHandle result = findFieldSetterHandle(memberName, elementJavaType); if (result == null) { result = findFieldPutHandle(memberName, elementJavaType); }// ww w. ja va2 s . c o m if (result == null) { String message = String.format("Could not find accessible setter or field for attribute [%s]", elementAlias); throw new QueryInfoException(message); } return result; }
From source file:com.evanzeimet.queryinfo.jpa.result.AbstractTupleToPojoQueryInfoResultConverter.java
protected Map<String, MethodHandle> mapElementMethodHandles(List<TupleElement<?>> tupleElements) throws QueryInfoException { int elementCount = tupleElements.size(); Map<String, MethodHandle> result = new HashMap<>(elementCount); Iterator<TupleElement<?>> elementIterator = tupleElements.iterator(); while (elementIterator.hasNext()) { TupleElement<?> element = elementIterator.next(); String elementAlias = element.getAlias(); MethodHandle methodHandle = getMethodHandleForElement(element); result.put(elementAlias, methodHandle); }// ww w. j ava 2 s . c om return result; }
From source file:org.fornax.cartridges.sculptor.framework.accessimpl.jpa2.JpaHelper.java
/** * * @param <T>/* w w w . j a va 2 s . c o m*/ * @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"); } }