Jmix JPA entities no longer serializable?

Jmix version: 1.1.1
Jmix Studio plugin version: 1.1.4-213
IntelliJ IDEA 2021.3 CE - Build #IC-213.5744.223, built on November 27, 2021
Operating System: macOS 12.0.1 (21A559)
File System: Case-Sensitive Journaled HFS+ (APFS)
Datebase: PostgreSQL 13

Hi Everyone

After performing the CUBA-to-Jmix migration I noticed in my CUBA code that provides a Map object for the CUBA Freemarker functionality, used for example in the CUBA EmailInfoBuilder setTemplateParameters() method, that my Jmix JPA entity is no longer serializable. Studio displays an error.

I assume that this was explicitly chosen for the new architecture but I am not 100% sure. Maybe there was a mistake during the CUBA-to-Jmix migration somewhere?

Can you please explain this?

Thanks in advance for your feedback.

Best regards

Making entity serializable is very easy, just add implements Serializable to its definition.

Jmix no longer requires entity definitions to be serializable, because there are no layer separation (web and core) anymore.

Hi Alexander

Thank you for confirming that this is by-design and not a CUBA-to-Jmix migration issue.

Best regards

In fact, Java serialization is still used when saving entities changed in UI screens. It’s done to isolate instances being saved from the screen content, essentially by making a copy of the object graph.

It’s true that you don’t have to declare implements Serializable in your entities source code, but it’s added by the bytecode enhancement at build time anyway. So if your entities contain any non-serializable fields, they should be marked with the transient modifier, otherwise they’ll cause exceptions when saved in UI.

Hi Konstantin

Thank you for the addition information and details.

Best regards