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

DataGrid aggregation doesn't work with composite entities #3253

Closed
KremnevDmitry opened this issue May 15, 2024 · 1 comment
Closed

DataGrid aggregation doesn't work with composite entities #3253

KremnevDmitry opened this issue May 15, 2024 · 1 comment
Assignees
Labels
in: flowui size: S type: bug Something isn't working
Milestone

Comments

@KremnevDmitry
Copy link
Contributor

Environment

Jmix version: 2.2.999-SNAPSHOT

Bug Description

Let's assume that two entities are defined: Order and OrderLineItem with a one-to-many @composition.
The OrderDetailView contains a DataGrid of OrderLineItem.

If you enable aggregation for this DatGrid and add multiple items, an error will occur.

Current Behavior

An error:

java.lang.IllegalArgumentException: entity or id is null
	at io.jmix.core.common.util.Preconditions.checkNotNullArgument(Preconditions.java:101)
	at io.jmix.flowui.model.impl.CollectionContainerImpl.getItemIndex(CollectionContainerImpl.java:123)
	at io.jmix.flowui.model.impl.CollectionContainerImpl.getItemOrNull(CollectionContainerImpl.java:117)
	at io.jmix.flowui.model.impl.CollectionContainerImpl.getItem(CollectionContainerImpl.java:108)
	at io.jmix.flowui.data.grid.ContainerDataGridItems.getItemValue(ContainerDataGridItems.java:208)
	at io.jmix.flowui.data.aggregation.impl.AggregatableDelegate.lambda$valuesByProperty$0(AggregatableDelegate.java:197)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)

Expected Behavior

Aggregation will be updated without any errors.

Sample Project

aggregationBug.zip

@KremnevDmitry KremnevDmitry self-assigned this May 15, 2024
@KremnevDmitry
Copy link
Contributor Author

UPD:

The error occurred because the io.jmix.core.entity.EntityValues#getId method was used as aggregation items ID provider.

Since composite entities receive their ID only after the parent entity is saved, this method of getting the ID would throw an error. Now io.jmix.core.entity.EntityValues#getIdOrEntity will be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: flowui size: S type: bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants