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

Ordered Entity removal breaks when there are multiple Entity types sharing one table #122

Open
jsavell opened this issue Nov 10, 2020 · 2 comments

Comments

@jsavell
Copy link
Member

jsavell commented Nov 10, 2020

When multiple Entity types share one table, position values will be duplicated.

Under these conditions, OrderedEntityService.findByPosition fails to return a unique entity value, leading to a non-unique result error and failure to delete.

public Object findByPosition(Class<?> clazz, Long position) {

@jsavell
Copy link
Member Author

jsavell commented Nov 10, 2020

My implementation suggestion is to refactor the OrderedEntityService to separate the deletion and reorder logic.

Client apps would then be able to override the deletion mechanism if needed, while still letting the reorder, which relies on the entity manager and more complex logic, do what it needs to do.

@ghost
Copy link

ghost commented Nov 11, 2020

I do not think separating deletion from reordering is the right approach. For an ordered entity when a delete occurs you must reorder or will have corrupt ordering. Reorder must continue to be a side-effect of deletion. I do think the extensibility of this service could be improved to afford to delete/reorder by a combination of properties in addition to the position.

I would recommend an additional method for overriding to add additional properties to the query conditions in conjunction with the position column.

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

No branches or pull requests

1 participant