hibernate / hibernate-models

An abstraction over "reflection" and annotations
Apache License 2.0
2 stars 5 forks source link

Add AnnotationTarget#getSingleAnnotationUsage #38

Closed sebersole closed 3 months ago

sebersole commented 3 months ago

AnnotationTarget#getAnnotationUsage is designed to throw an exception if more than one exists (repeatable annotations). E.g. given

@Entity
class Stuff {
    ...
    @JoinColumn(...)
    @JoinColumn(...)
    Things things;
}

a call to FieldDetails("things").getAnnotationUsage(JoinColumn.class) will result in a AnnotationAccessException being thrown.

Add a method AnnotationTarget#getSingleAnnotationUsage which simply returns null in these cases.