Add support for OffsetDateTime in Pivottable

Hi Team,

The pivottable add-on does’t support OffsetDateTime field, specifically in JmixPivotTableSerializer. Could you please add support for this?

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.OffsetDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (or disable `MapperFeature.REQUIRE_HANDLERS_FOR_JAVA8_TIMES`) (through reference chain: java.util.ImmutableCollections$ListN[0]->java.util.HashMap["时间"])
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1359) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.impl.UnsupportedTypeSerializer.serialize(UnsupportedTypeSerializer.java:34) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeOptionalFields(MapSerializer.java:868) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serializeWithoutTypeInfo(MapSerializer.java:759) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:719) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.std.MapSerializer.serialize(MapSerializer.java:34) ~[jackson-databind-2.19.0.jar:2.19.0]
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119) ~[jackson-databind-2.19.0.jar:2.19.0

Hi,

Thank you for your suggestion to improve the component.
I have created the ticket.

As workaround, you can extend PivotTable component, override createSerializer method, add necessary serializers and use this custom component in your project.

Best regards,
Ilya

2 Likes

Hi everyone,

I found this discussion because I encountered the same error. I’m glad you created the issue.

I would like to add the information that the missing support for OffsetDateTime makes it nearly impossible to include entity type properties to pivot tables if the entity has audit traits like createdDate and lastModifiedDate. For example, if you create a pivot table for Orders and want to add Customer as a property. I tried to remove the createdDate and lastModifiedDate of the entity from the fetchPlan, but this caused unfetched errors, it seemed like the JSON Serializer expected the attributes:

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Cannot get unfetched attribute [createdDate] from detached object com.company.demo.domain.Customer-019a9bbd-cbc5-7cb6-9bc1-a9102b951f0d [detached]. (through reference chain: java.util.ImmutableCollections$ListN[0]->java.util.HashMap["Customer"]->com.company.demo.domain.Customer["createdDate"])

Am I missing something here? Thanks in advance.

Best regards,

Jana

Hi Jana,

You can provide the entity classes and the descriptor with the pivot table (or a demo project with an example of the issue). I will send back the project with the fix.

Thanks,
Ilya

Hi Ilya,

thank you! I added a zipped User-Order demo project. You’ll find the issues in the OrderPivotTableView.

Best regards,

Jana

pivottable-date-serializer.zip (101.2 KB)

Jana, please, take a look at the updated project. I have a few notes to share:

  1. You specified the user property in the pivot properties. The component will display it as [Object...] because it doesn’t have a serializer for this type. It’s better to specify user.username instead.
  2. As the original issue hasn’t been resolved yet, I’ve implemented a workaround:
    • I extended the PivotTable component and created a custom serializer with OffsetDateTime support.
    • Created custom component loader to create the custom pivot table component
    • Overridden the CustomComponentsLoaderConfig bean to launch custom pivot table loader.

If you have any additional questions or need further clarification, feel free to reach out.

Best regards,
Ilya

pivottable-date-serializer.zip (103.0 KB)

1 Like

Hi Ilya,

thanks a lot, I have included your fix in our project.
Your first suggestion is also really helpful, this change solved my problem and displays what I expected from inluding just the user property.

Best regards,

Jana

1 Like