Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-1404

AuditorAware#getCurrentAuditor called for Entities only marked CreatedAt

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Waiting for Feedback
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0.10 (Kay SR10)
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      spring-data-commons 2.0.10

      Description

      When we have below two entities.

       

      @Entity
      @EntityListeners(AuditingEntityListener.class)
      public class EntityWithCreatedBy { 
        @Id @GeneratedValue private Integer id;
      
        @ManyToOne(fetch = FetchType.LAZY)
        @CreatedBy 
        private User createdBy;
      }

       

      @Entity
      @EntityListeners(AuditingEntityListener.class)
      public class EntityWithOnlyCreatedAt {
      
        @Id
        @GeneratedValue
        private Integer id;
      
        @CreatedDate
        private LocalDateTime createdDate;
      }
      

      And try to save them, then `org.springframework.data.domain.AuditorAware#getCurrentAuditor` was called for both of them.

       

      It would be nice when we save entity that does not have `@CreatedBy` or `@LastModifiedBy`,

      `AuditorAware#getCurrentAuditor` stop being called.

       

      I attached reproduction project (by spring-data-jpa) to Reference URL.

       

        Attachments

          Activity

            People

            Assignee:
            olivergierke Oliver Drotbohm
            Reporter:
            Yuki YOSHIDA Yuki Yoshida
            Last updater:
            Mathias Ewald
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: