use of javassist.bytecode.annotation.AnnotationMemberValue in project BroadleafCommerce by BroadleafCommerce.
the class QueryConfigurationClassTransformer method prepareNamedQueries.
/**
* Prepare the {@link NamedQueries} declaration
*
* @param constantPool
* @param pool
* @param queryArray
* @throws NotFoundException
*/
protected void prepareNamedQueries(ConstPool constantPool, ClassPool pool, ArrayMemberValue queryArray) throws NotFoundException {
List<MemberValue> values;
if (queryArray.getValue() != null) {
values = new ArrayList<MemberValue>(Arrays.asList(queryArray.getValue()));
} else {
values = new ArrayList<MemberValue>();
}
for (NamedQuery query : namedQueries) {
Annotation namedQuery = new Annotation(NamedQuery.class.getName(), constantPool);
StringMemberValue name = new StringMemberValue(constantPool);
name.setValue(query.name());
namedQuery.addMemberValue("name", name);
StringMemberValue queryString = new StringMemberValue(constantPool);
queryString.setValue(query.query());
namedQuery.addMemberValue("query", queryString);
EnumMemberValue lockMode = (EnumMemberValue) Annotation.createMemberValue(constantPool, pool.makeClass("LockModeType"));
lockMode.setType(LockModeType.class.getName());
lockMode.setValue(query.lockMode().toString());
namedQuery.addMemberValue("lockMode", lockMode);
List<AnnotationMemberValue> queryHints = new ArrayList<AnnotationMemberValue>();
for (QueryHint hint : query.hints()) {
prepareQueryHints(constantPool, queryHints, hint);
}
ArrayMemberValue hintArray = new ArrayMemberValue(constantPool);
hintArray.setValue(queryHints.toArray(new AnnotationMemberValue[queryHints.size()]));
namedQuery.addMemberValue("hints", hintArray);
AnnotationMemberValue queryAnnotation = new AnnotationMemberValue(namedQuery, constantPool);
values.add(queryAnnotation);
}
queryArray.setValue(values.toArray(new MemberValue[values.size()]));
}
Aggregations