Spring Data JPA
  1. Spring Data JPA
  2. DATAJPA-265

Make it possible to configure auditing with Java Config

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2 GA
    • Fix Version/s: 1.5 M1 (Codd)
    • Component/s: None

      Description

      Currently it's not possible to configure auditing in java configuration.

      The "<jpa:auditing>"-tag is the last piece of XML configuration in some of my projects, so being able to configure that part as well in Java configuration would be cool.

        Issue Links

          Activity

          Hide
          Ranie Jade Ramiso added a comment -

          Is anyone already working on this? If none, I could take a look at it.

          Show
          Ranie Jade Ramiso added a comment - Is anyone already working on this? If none, I could take a look at it.
          Hide
          Oliver Gierke added a comment -

          Nope, nothing done about this so far. Might be a good idea to split things up into a JPA specific part and one that could go into commons, similarly to the XML namespace implementation.

          Show
          Oliver Gierke added a comment - Nope, nothing done about this so far. Might be a good idea to split things up into a JPA specific part and one that could go into commons, similarly to the XML namespace implementation.
          Hide
          Ranie Jade Ramiso added a comment -

          Here's what have I done so far https://gist.github.com/raniejade/7c059dea7a9c76cc1f6b. I'm not really confident about it, could you take a look at it? I'm pretty new using the bean definition builder.

          Show
          Ranie Jade Ramiso added a comment - Here's what have I done so far https://gist.github.com/raniejade/7c059dea7a9c76cc1f6b . I'm not really confident about it, could you take a look at it? I'm pretty new using the bean definition builder.
          Hide
          Ranie Jade Ramiso added a comment -

          Just an update, made a pull request for this in the commons and jpa repo.

          Show
          Ranie Jade Ramiso added a comment - Just an update, made a pull request for this in the commons and jpa repo.
          Hide
          Nick Williams added a comment -

          Ranie, your pull request is missing a replacement for the XML attribute modify-on-creation.

          I actually favor omitting dateTimeProviderRef in Java config, because I think DateTimeProvider should be deprecated since it only supports Joda Time and auditing should not (and perhaps already does not) only support Joda Time. It should (and perhaps already does) support java.util.Date, java.util.Calendar, and java.sql.Timestamp. It should also support the new Java 8 Date & Time types (see DATAJPA-385). DateTimeProvider is not compatible with any of that.

          Finally, I think auditing config might work better as an interface that an @Configuration class can implement rather than an annotation. This way, the AuditorAware can be returned in a compile-safe way instead of referenced in an unsafe String property. But that's just my $0.02.

          Show
          Nick Williams added a comment - Ranie, your pull request is missing a replacement for the XML attribute modify-on-creation . I actually favor omitting dateTimeProviderRef in Java config, because I think DateTimeProvider should be deprecated since it only supports Joda Time and auditing should not (and perhaps already does not) only support Joda Time. It should (and perhaps already does) support java.util.Date , java.util.Calendar , and java.sql.Timestamp . It should also support the new Java 8 Date & Time types (see DATAJPA-385 ). DateTimeProvider is not compatible with any of that. Finally, I think auditing config might work better as an interface that an @Configuration class can implement rather than an annotation. This way, the AuditorAware can be returned in a compile-safe way instead of referenced in an unsafe String property. But that's just my $0.02.
          Hide
          Olli Varis added a comment - - edited

          Hi, Any update on this one? Is it really so that Audition can be only configure using XML currently? That's not too convienent since everything else (even Spring Security (RC2)) can be configured via JavaConfig.

          Show
          Olli Varis added a comment - - edited Hi, Any update on this one? Is it really so that Audition can be only configure using XML currently? That's not too convienent since everything else (even Spring Security (RC2)) can be configured via JavaConfig.
          Hide
          Yuan Ji added a comment -

          It will be very nice to have this feature in all SpringData projects. So far <mongo:auditing> is the only piece of XML code left.

          Show
          Yuan Ji added a comment - It will be very nice to have this feature in all SpringData projects. So far <mongo:auditing> is the only piece of XML code left.
          Hide
          Thomas Darimont added a comment -

          Added PR: https://github.com/spring-projects/spring-data-jpa/pull/50

          @Yuan Ji: You should have a look at: DATAMONGO-792

          Show
          Thomas Darimont added a comment - Added PR: https://github.com/spring-projects/spring-data-jpa/pull/50 @Yuan Ji: You should have a look at: DATAMONGO-792
          Hide
          Thomas Darimont added a comment -

          Please revise.

          Show
          Thomas Darimont added a comment - Please revise.

            People

            • Assignee:
              Thomas Darimont
              Reporter:
              Aleksander Blomskøld
            • Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile