javax.persistence.metamodel.StaticMetamodel Java Examples

The following examples show how to use javax.persistence.metamodel.StaticMetamodel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Generator.java    From spring-data-jpa-entity-graph with MIT License 5 votes vote down vote up
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  if (roundEnv.processingOver() || annotations.isEmpty()) {
    return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
  }

  roundEnv
      .getElementsAnnotatedWith(StaticMetamodel.class)
      .stream()
      .map(TypeElement.class::cast)
      .map(typeElement -> new MetamodelClass(elements, types, typeElement))
      .forEach(metamodelClass -> metamodelClass.writeEntityGraphTo(filer));

  return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
 
Example #2
Source File: MysqlQueryBuilderImpl3.java    From zstack with Apache License 2.0 5 votes vote down vote up
private void populateEntityInfo() throws NoSuchMethodException {
    Set<Class<?>> metaClasses = BeanUtils.reflections.getTypesAnnotatedWith(StaticMetamodel.class);
    for (Class it : metaClasses) {
        StaticMetamodel at = (StaticMetamodel) it.getAnnotation(StaticMetamodel.class);
        metaModelClasses.put(at.value(), it);
    }

    Set<Class<?>> invClasses = BeanUtils.reflections.getTypesAnnotatedWith(Inventory.class);

    for (Class invClass : invClasses) {
        EntityInfo info = buildEntityInfo(invClass);

        if (info.inventoryAnnotation.parent().length > 0) {
            Parent pat = info.inventoryAnnotation.parent()[0];
            Class pinvClass = pat.inventoryClass();
            DebugUtils.Assert(pinvClass.isAnnotationPresent(Inventory.class), String.format("inventory[%s]'s parent inventory class[%s] is not annotated by @Inventory", info.inventoryClass.getName(), pinvClass.getName()));
            EntityInfo pinfo = buildEntityInfo(pinvClass);
            info.parent = pinfo;
            pinfo.children.add(info);
        }

    }

    for (EntityInfo e : entityInfos.values()) {
        e.buildFlatTypeEntityMap();
    }
}
 
Example #3
Source File: Generator.java    From spring-data-jpa-entity-graph with MIT License 4 votes vote down vote up
@Override
public Set<String> getSupportedAnnotationTypes() {
  return Collections.singleton(StaticMetamodel.class.getCanonicalName());
}