Skip to content

7.1.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension#15118

Merged
codeconsole merged 43 commits intoapache:7.1.xfrom
codeconsole:7.0.x-autotimestamp-enhancements
Nov 12, 2025
Merged

7.1.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension#15118
codeconsole merged 43 commits intoapache:7.1.xfrom
codeconsole:7.0.x-autotimestamp-enhancements

Conversation

@codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Oct 6, 2025

Introduce @CreatedDate, @LastModifiedDate, @CreatedBy, and @LastModifiedBy similar to Spring Data

Example App: ./gradlew :grails-test-examples-scaffolding:bootRun

Introduce grails.importGrailsCommonAnnotations to automatically import common grails annotations and jakarta.validation.constraints.*

build.gradle

grails {
    importJavaTime = true
    importGrailsCommonAnnotations = true // kitchen sink
    starImports = ['java.util.concurrent', 'groovy.transform'] // fully customizable
}

allows the following with no imports

class User {
    String firstName
    String lastName
    String email
    @CreatedDate Instant created
    @LastModifiedDate Instant modified
}

class Car {
    String make
    String model
    @CreatedBy User owner
    @LastModifiedBy User driver
    @CreatedDate Instant purchased
    @LastModifiedDate Instant lastDriven
}
    @Bean
    AuditorAware<User> springSecurityAuditorAware() {
        return new AuditorAware< User >() {
            @Override
            Optional<String> getCurrentAuditor() {
                Optional.ofNullable(SecurityContextHolder.context)
                        .map { it.authentication }
                        .filter { it?.authenticated }
                        .map { (User) it.principal }
            }
        }
    }
@Scaffold(GormService<User>)
class UserService implements UserDetailsService {
    @Override
    UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        return User.findByEmail(username)
    }
}
import grails.plugin.scaffolding.RestfulServiceController

@Scaffold(RestfulServiceController<User>)
class UserController {}

…erties will only be marked dirty if other updates exist. This mimics the behavior in hibernate. Fixes apache#15120
@jdaugherty
Copy link
Contributor

Per the weekly meeting, we'll merge this into 7.1. The vote to create that branch is going now - once 72 hrs have passed, we'll create the branch.

@jdaugherty
Copy link
Contributor

@codeconsole Can you update this PR now that you've made your mongo update date fixes?

@codeconsole
Copy link
Contributor Author

@codeconsole Can you update this PR now that you've made your mongo update date fixes?

Done

@codeconsole codeconsole requested a review from matrei November 7, 2025 00:11
Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it's a bad idea to being walking the dependency graph on every apply. I won't stop this merge since the default is to not include them though.

I think the only thing that needs to be done to merge this is to update the documentation to inform people of these features.

@codeconsole codeconsole merged commit 162ff83 into apache:7.1.x Nov 12, 2025
58 of 59 checks passed
@codeconsole
Copy link
Contributor Author

#15232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants