public class AuditMetadataUtils extends java.lang.Object
Utility class for detecting and caching audit metadata annotations on domain properties. This avoids repeated reflection calls by storing the annotation type in the Property metadata.
Supports the following annotations (both GORM and Spring Data variants):
@CreatedDate / @grails.gorm.annotation.CreatedDate - automatically set on insert@LastModifiedDate / @grails.gorm.annotation.LastModifiedDate - automatically set on insert and update@CreatedBy / @grails.gorm.annotation.CreatedBy - automatically populated with current auditor on insert@LastModifiedBy / @grails.gorm.annotation.LastModifiedBy - automatically populated with current auditor on insert and update@AutoTimestamp - GORM-specific annotation for backwards compatibilityCaching behavior is controlled by the grails.gorm.events.autoTimestampCacheAnnotations
configuration property. When disabled (typically in development mode), annotation changes during
class reloading are immediately recognized. When enabled (production mode), annotations are cached
for optimal performance.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static AuditMetadataType |
getAuditMetadataType(PersistentProperty<?> persistentProperty, boolean cacheAnnotations)Gets the audit metadata type for a persistent property, using cached metadata when caching is enabled. |
|
public static boolean |
hasAuditMetadataAnnotation(PersistentProperty<?> persistentProperty, boolean cacheAnnotations)Checks if a property has any audit metadata annotation. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Gets the audit metadata type for a persistent property, using cached metadata when caching is enabled.
When caching is disabled (typically in development mode), this method will always perform reflection to detect the current annotation state, ensuring that annotation changes during class reloading are immediately recognized. When caching is enabled (production mode), the result is cached to avoid repeated reflection calls.
persistentProperty - The persistent property to checkcacheAnnotations - Whether to cache the annotation metadataChecks if a property has any audit metadata annotation.
persistentProperty - The persistent property to checkcacheAnnotations - Whether to cache the annotation metadata@CreatedDate, @LastModifiedDate,
@CreatedBy, @LastModifiedBy, or @AutoTimestamp) from either GORM or Spring Data