Skip to content

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

@jdaugherty
Copy link
Contributor

I've updated 7.1.x with the latest 7.0.x changes. Can you please merge 7.1.x into this PR so the changes are reflected?

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.

My largest problem is the breaking change with the isDevelopmentMode(). We need a better solution here. Can you give your reasoning for disabling the caching in development mode?

@codeconsole
Copy link
Contributor Author

My largest problem is the breaking change with the isDevelopmentMode(). We need a better solution here. Can you give your reasoning for disabling the caching in development mode?

@jdaugherty You are looking at it from the wrong perspective. I am introducing caching when not in development mode. The current implementation has no caching. The performance benefit is so negligible that I suspect you wouldn't even notice.

@jdaugherty
Copy link
Contributor

We should just always cache. We don't need the dependency that way.

@codeconsole codeconsole changed the title 7.0.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension 7.1.x AutoTmestamp Enhancements + grails.importGrailsAnnotations GrailsExtension Nov 2, 2025
@codeconsole codeconsole requested a review from matrei November 7, 2025 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants