-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19912 Add automatic test data cleanup feature to @SessionFactory annotation #11203
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
base: main
Are you sure you want to change the base?
Conversation
ea9ba16 to
374fdb8
Compare
hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SessionFactoryExtension.java
Outdated
Show resolved
Hide resolved
786f305 to
ad5c292
Compare
ad5c292 to
02679d8
Compare
|
I still wonder if we want to allow multiple options here (array attribute). Its hidden in the Jira a bit, but I mean specifically this thought - DropDataTiming[] dropTestData() default {}What do you think? |
|
@sebersole Good idea! I think using BEFORE_EACH and AFTER_EACH together doesn't provide significant benefits. However, combining BEFORE_ALL or AFTER_ALL with other timing options would be quite effective. If you agree, I'll modify the implementation to support multiple timing values as an array. If using an array, we would need to handle cases where NEVER is used together with other timings. How about throwing an exception like ValidationMode does? |
|
You can just get rid of NEVER in that case. NEVER is effectively |
|
@sebersole "Thanks for the feedback! Just to confirm my understanding - when NEVER is used with other timing values like {NEVER, BEFORE_ALL}, you're suggesting to simply remove NEVER and execute only {BEFORE_ALL}, correct? |
|
No, not quite. I'm saying remove NEVER as an enum value. Given the definition: DropDataTiming[] dropTestData() default {}The default is exactly the same as "never". |
|
@sebersole Ah, I understand now! I'll modify the implementation to remove the NEVER enum value and update the logic accordingly. |
|
More concretely... public enum DropDataTiming {
BEFORE_EACH,
AFTER_EACH,
BEFORE_ALL,
AFTER_ALL
}
@interface SessionFactory {
...
DropDataTiming[] dropTestData() default {}
}Also, I'd consider adding : interface SessionFactoryProducer {
static final DropDataTiming[] NONE = new DropDataTiming[0];
default DropDataTiming[] dropTestData() {
return NONE;
}
} |
02679d8 to
712d735
Compare
|
@sebersole Thanks for the feedback! I've implemented the default {} approach. |
Correct |
[Please describe here what your change is about]
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-19912