Skip to content

Conversation

codeconsole
Copy link
Contributor

@codeconsole codeconsole commented Oct 6, 2025

Introduce @CreatedDate and @LastModifiedDate similar to Spring Data

Introduce grails.importGrailsAnnotations to automatically import common grails annotations.

build.gradle

grails {
    importJavaTime = true
    importGrailsAnnotations = true
}

allows the following with no imports

class User {
    String firstName
    String lastName
    String email
    @CreatedDate Instant created
    @LastModifiedDate Instant modified
}
@Scaffold(domain = User)
class UserService {}
import grails.plugin.scaffolding.RestfulServiceController

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

Comment on lines +247 to +253
// Check for grails-scaffolding (grails.plugin.scaffolding.annotation.*)
def scaffoldingDep = project.configurations.getByName('compileClasspath').dependencies.find { Dependency d ->
d.group == 'org.apache.grails' && d.name == 'grails-scaffolding'
}
if (scaffoldingDep) {
starImports.add('grails.plugin.scaffolding.annotation')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

While I understand why you added it while at it, this technically does not have anything to do with time.
It should probably be in a subsequent PR?

Copy link
Contributor Author

@codeconsole codeconsole Oct 8, 2025

Choose a reason for hiding this comment

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

@sbglasius I agree it could of been in a separate PR, but it's kind of a gray area because the added config is importGrailsAnnotations and that is just adding 1 annotation @Scaffold. Plus there is a lot I want to address and the latency in getting PRs reviewed is a bit slow at the moment for what I want to get added/fixed.

The motivation for this PR is actually for importGrailsAnnotations. I was originally against
@matrei 's suggest of having 2 different annotations for AutoTimestamp because of the extra import statement on every domain class, but with importGrailsAnnotations, I don't mind.

In fact, with importGrailsAnnotations, I am even willing to get rid of @AutoTimestamp now. @matrei what are your thoughts about getting rid of @AutoTimestamp?

…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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants