/**
*
* Append the entity attribute name to the JPQL query statement.
*
* @param jpqlStatement
* @param jpaEntity
* @param attribute
* @throws java.lang.SecurityException
* @throws NoSuchFieldException
* @throws ClassNotFoundException
*/
private void appendEntityAttributeName(StringBuilder jpqlStatement, JpaEntity jpaEntity, EntityAttribute attribute, AtomicInteger aliasUnicityKey, AtomicInteger joinAdditionsOffset) throws NoSuchFieldException, java.lang.SecurityException, ClassNotFoundException {
Class<?> entityClass = Class.forName(jpaEntity.getClassName());
Field field = entityClass.getDeclaredField(attribute.getAttributeName());
boolean isJointRelationship =
field.getAnnotation(OneToOne.class) != null
|| field.getAnnotation(OneToMany.class) != null
|| field.getAnnotation(ManyToOne.class) != null
|| field.getAnnotation(ManyToMany.class) != null;
if(isJointRelationship) {
StringBuilder joinFragment = new StringBuilder();
Queue<String> objectTreePath = extractDotSeparatedPathFragments(attribute.getPossibleValueLabelAttributePath());
completeJoinFragment(joinFragment, entityClass, objectTreePath, aliasUnicityKey);
jpqlStatement.insert(joinAdditionsOffset.get(), joinFragment);
joinAdditionsOffset.set(joinAdditionsOffset.get() + joinFragment.length());
jpqlStatement.append(" x").append(aliasUnicityKey.get()).append('.').append(attribute.getPossibleValueLabelAttribute());
} else {
jpqlStatement.append(" x.").append(attribute.getAttributeName());
}
}
DefaultQueryModelService.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:infiniquery-core
作者:
评论列表
文章目录