use of jakarta.persistence.Access in project hibernate-orm by hibernate.
the class PropertyContainer method collectPersistentAttributesUsingLocalAccessType.
private static void collectPersistentAttributesUsingLocalAccessType(XClass xClass, TreeMap<String, XProperty> persistentAttributeMap, Map<String, XProperty> persistentAttributesFromGetters, List<XProperty> fields, List<XProperty> getters) {
// Check fields...
Iterator<XProperty> propertyIterator = fields.iterator();
while (propertyIterator.hasNext()) {
final XProperty xProperty = propertyIterator.next();
final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
if (localAccessAnnotation == null || localAccessAnnotation.value() != jakarta.persistence.AccessType.FIELD) {
continue;
}
propertyIterator.remove();
persistentAttributeMap.put(xProperty.getName(), xProperty);
}
// Check getters...
propertyIterator = getters.iterator();
while (propertyIterator.hasNext()) {
final XProperty xProperty = propertyIterator.next();
final Access localAccessAnnotation = xProperty.getAnnotation(Access.class);
if (localAccessAnnotation == null || localAccessAnnotation.value() != jakarta.persistence.AccessType.PROPERTY) {
continue;
}
propertyIterator.remove();
final String name = xProperty.getName();
// HHH-10242 detect registration of the same property getter twice - eg boolean isId() + UUID getId()
final XProperty previous = persistentAttributesFromGetters.get(name);
if (previous != null) {
throw new org.hibernate.boot.MappingException(LOG.ambiguousPropertyMethods(xClass.getName(), HCANNHelper.annotatedElementSignature(previous), HCANNHelper.annotatedElementSignature(xProperty)), new Origin(SourceType.ANNOTATION, xClass.getName()));
}
persistentAttributeMap.put(name, xProperty);
persistentAttributesFromGetters.put(name, xProperty);
}
}
Aggregations