Skip to content
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

Allow configuring the order of built-in EntityCallbacks #4914

Open
rfelgent opened this issue Mar 8, 2025 · 4 comments
Open

Allow configuring the order of built-in EntityCallbacks #4914

rfelgent opened this issue Mar 8, 2025 · 4 comments
Assignees
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement

Comments

@rfelgent
Copy link
Contributor

rfelgent commented Mar 8, 2025

Hi @mp911de ,

the @Order of the built-in EntityCallbacks (at the time of writing AuditingEntityCallback and ValidatingEntityCallback) is not distinctive, both have the same configuration

        @Override
	public int getOrder() {
		return 100;
	}

Furthermore, I would like to make the value referencable by exposing them as public constant, e.g.:

public static final int ORDER = xxx;

This change allows a clean code regarding ordering of the buit-in and app provided EntityCallbacks.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 8, 2025
@mp911de
Copy link
Member

mp911de commented Mar 10, 2025

Auditing and validation should be orthogonal aspects that ideally should not affect each other. We're using Order to avoid falling into the Ordered.LOWEST_PRECEDENCE basket.

This change allows a clean code regarding ordering of the buit-in and app provided EntityCallbacks.

I am not quite sure how this would really help as the value is a static one. I could imagine on the other side to introduce setOrder(…) to configure ordering. That is a common pattern in Spring Framework (e.g. UrlBasedViewResolver, ProxyProcessorSupport) providing quite some flexibility to change ordering.

@mp911de mp911de self-assigned this Mar 10, 2025
@rfelgent
Copy link
Contributor Author

Hi @mp911de ,

I am not sure, If I could make clear the concerns regarding similar @Order values.

How do you know the order of entity callback if they all have the same order ? I think, there is already some kind of dependencies between callbacks.
Example: The AuditingCallback might manipulate fields annotated with @NotNull (e.g. modifiedBy). Therefore, I would like to have a guaranteed order, that the ValidatingEntityCallback gets triggered as last.

@mp911de
Copy link
Member

mp911de commented Mar 10, 2025

Isn't using @NotNull on a @LastModifiedBy like writing a unit test to verify the framework is working correctly? That being said, I'm not sure what type of issue you're trying to solve.

Apart from that, introducing setOrder(…) on our callback implementations, enabling your application to customize the order, is totally fine with us.

@rfelgent
Copy link
Contributor Author

I will Provide a merge request

@mp911de mp911de added status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 11, 2025
@mp911de mp911de changed the title make the @Order of built-in EntityCallbacks distinctive and usable Allow configuring the order of built-in EntityCallbacks Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ideal-for-contribution An issue that a contributor can help us with type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants