Skip to content

Not allow to modify dateCreated ? #14449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
abcfy2 opened this issue Aug 21, 2019 · 3 comments
Open

Not allow to modify dateCreated ? #14449

abcfy2 opened this issue Aug 21, 2019 · 3 comments

Comments

@abcfy2
Copy link
Contributor

abcfy2 commented Aug 21, 2019

Issue link: apache/grails-data-mapping#1249

When GORM version is greater than 6.1.11, will nolonger to change the dateCreated anymore.

I find the reason is:

https://github.com/grails/gorm-hibernate5/blob/408b681658ee24ff13db3b6c20c9ea290756ec3b/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/support/ClosureEventTriggeringInterceptor.java#L205-L208

I don't know why you're not allow to modify dateCreated ?

abcfy2 referenced this issue in abcfy2/grails-rest-seed Aug 21, 2019
基本没有改动业务代码部分,只是升级了框架。

需要注意GROM这个版本不能改动`dateCreated`了,参见issue: https://github.com/grails/gorm-hibernate5/issues/149

另外发现Grails 4.0.0版本会有一些Bean缺失的问题,比如ValueConvertor缺失的问题,参考issue: apache/grails-core#11387

因此这版本暂时采用手工初始化Jsr310DataBinding bean的方案
abcfy2 referenced this issue in abcfy2/grails-rest-seed Aug 21, 2019
基本没有改动业务代码部分,只是升级了框架。

需要注意GROM这个版本不能改动`dateCreated`了,参见issue: https://github.com/grails/gorm-hibernate5/issues/149

另外发现Grails 4.0.0版本会有一些Bean缺失的问题,比如ValueConvertor缺失的问题,参考issue: apache/grails-core#11387

因此这版本暂时采用手工初始化Jsr310DataBinding bean的方案

TODO:

测试使用的http client换成`io.micronaut:micronaut-http-client`(testCompile 'io.micronaut:micronaut-http-client')
abcfy2 referenced this issue in abcfy2/grails-rest-seed Aug 21, 2019
基本没有改动业务代码部分,只是升级了框架。

需要注意GROM这个版本不能改动`dateCreated`了,参见issue: https://github.com/grails/gorm-hibernate5/issues/149

另外SpringSecurity新版本修改了密码策略,会在加密的密码前添加前缀,参见: https://grails-plugins.github.io/grails-spring-security-core/4.0.x/index.html#newInV3

不过按照SpringSeciruty的官方文档叙述,依旧是兼容旧版本的密码解密的(不带前缀的密码)

另外发现Grails 4.0.0版本会有一些Bean缺失的问题,比如ValueConvertor缺失的问题,参考issue: apache/grails-core#11387

因此这版本暂时采用手工初始化Jsr310DataBinding bean的方案

TODO:

测试使用的http client换成`io.micronaut:micronaut-http-client`(testCompile 'io.micronaut:micronaut-http-client')
foxgem referenced this issue in DTeam-Top/grails-rest-seed Aug 22, 2019
基本没有改动业务代码部分,只是升级了框架。

需要注意GROM这个版本不能改动`dateCreated`了,参见issue: https://github.com/grails/gorm-hibernate5/issues/149

另外SpringSecurity新版本修改了密码策略,会在加密的密码前添加前缀,参见: https://grails-plugins.github.io/grails-spring-security-core/4.0.x/index.html#newInV3

不过按照SpringSeciruty的官方文档叙述,依旧是兼容旧版本的密码解密的(不带前缀的密码)

另外发现Grails 4.0.0版本会有一些Bean缺失的问题,比如ValueConvertor缺失的问题,参考issue: apache/grails-core#11387

因此这版本暂时采用手工初始化Jsr310DataBinding bean的方案

TODO:

测试使用的http client换成`io.micronaut:micronaut-http-client`(testCompile 'io.micronaut:micronaut-http-client')
@codeconsole
Copy link
Contributor

I think this is related to this?

grails/grails-data-hibernate5#146

@abcfy2
Copy link
Contributor Author

abcfy2 commented Aug 25, 2019

Yes, that's true. Since GORM 6.0.11 does not allow to modify dateCreated, and I find the source code. If you changed the dateCreated, it will be dismissed.

@tircnf
Copy link

tircnf commented Dec 19, 2023

https://gorm.grails.org/latest/hibernate/manual/index.html section 8.1.9

Make sure and flush the session is flushed inside the closure.

//Only the dateCreated property handling will be disabled for only the Foo domain
autoTimestampEventListener.withoutDateCreated(Foo) {
    new Foo(dateCreated: new Date() - 1).save(flush: true)
}

//Only the lastUpdated property handling will be disabled for only the Foo and Bar domains
autoTimestampEventListener.withoutLastUpdated(Foo, Bar) {
    new Foo(lastUpdated: new Date() - 1, bar: new Bar(lastUpdated: new Date() + 1)).save(flush: true)
}

//All timestamp property handling will be disabled for all domains
autoTimestampEventListener.withoutTimestamps {
    new Foo(dateCreated: new Date() - 2, lastUpdated: new Date() - 1).save(flush: true)
    new Bar(dateCreated: new Date() - 2, lastUpdated: new Date() - 1).save(flush: true)
    new FooBar(dateCreated: new Date() - 2, lastUpdated: new Date() - 1).save(flush: true)
}```

@jdaugherty jdaugherty transferred this issue from grails/grails-data-hibernate5 Mar 13, 2025
@jdaugherty jdaugherty transferred this issue from apache/grails-data-mapping Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants