Пример #1
0
 /**
  * Get {@link javax.persistence.AccessType } from {@link javax.persistence.Access @Access} on the
  * attribute of the given class
  */
 static XMLAccessType getAccessFromAttributeAnnotation(
     DotName className, String attributeName, IndexBuilder indexBuilder) {
   Map<DotName, List<AnnotationInstance>> indexedAnnotations =
       indexBuilder.getIndexedAnnotations(className);
   if (indexedAnnotations != null && indexedAnnotations.containsKey(ACCESS)) {
     List<AnnotationInstance> annotationInstances = indexedAnnotations.get(ACCESS);
     if (MockHelper.isNotEmpty(annotationInstances)) {
       for (AnnotationInstance annotationInstance : annotationInstances) {
         AnnotationTarget indexedPropertyTarget = annotationInstance.target();
         if (indexedPropertyTarget == null) {
           continue;
         }
         if (JandexHelper.getPropertyName(indexedPropertyTarget).equals(attributeName)) {
           XMLAccessType accessType =
               JandexHelper.getValueAsEnum(annotationInstance, "value", XMLAccessType.class);
           /** here we ignore @Access(FIELD) on property (getter) and @Access(PROPERTY) on field */
           XMLAccessType targetAccessType = annotationTargetToAccessType(indexedPropertyTarget);
           if (accessType.equals(targetAccessType)) {
             return targetAccessType;
           } else {
             LOG.warn(
                 String.format(
                     "%s.%s has @Access on %s, but it tries to assign the access type to %s, this is not allowed by JPA spec, and will be ignored.",
                     className, attributeName, targetAccessType, accessType));
           }
         }
       }
     }
   }
   return null;
 }
 @Override
 public void execute(Connection connection) {
   final String command =
       session.getFactory().getDialect().getDropTemporaryTableString()
           + ' '
           + persister.getTemporaryIdTableName();
   try {
     Statement statement = connection.createStatement();
     try {
       statement = connection.createStatement();
       statement.executeUpdate(command);
     } finally {
       try {
         statement.close();
       } catch (Throwable ignore) {
         // ignore
       }
     }
   } catch (Exception e) {
     log.warn("unable to drop temporary id table after use [" + e.getMessage() + "]");
   }
 }