Possible bug in EntitySnapshotManager


I am a Cuba development license owner.

I am developing an application, which relies on Snapshots. I am snapshotting an object, which has references to other objects.

I am using a view, which includes the necessary details of referenced objects, but when I invoke createSnaphot, I am getting a Snapshot XML containing ONLY the local properties.

I’ve traced the code to EntitySnapshotManager(158) - createSnapshot and I see, that

on line 177 setViewXml, viewSerializationAPI.toJson i correctly invoked and returns correct XML, but on the next line 178, entitySerializationAPI.toJson is invoked only with one param (entity) which lets the serialization API to work in the way as view param is provided as null.

Respectively, the view param provided to createSnapshot looks like is effectively ignored.

Could you, please, check if this is a real bug, because this problem actually currently puts the whole “history” functionality of the system on hold (we use snapshots to store historical info, which includes also info about referenced objects).

Thank you,


Hi Delyan,

EntitySerializationAPI.toJson converts to JSON entity with all loaded referenced objects (if view isn’t specified). Entity, that passed to the EntitySnapshotAPI#createSnapshot should be loaded with same view == view param.
Could you provide a sample application for your case?
Subbotin Andrey

Pls, let me know how I can send you source code of the app. I don’t want to upload it on a public server. My email is dido@musala.com

Hi Delyan,

You can send source code to our email: info@cuba-platform.com



Let’s summarize, that entity passed to the EntitySnapshotAPI#createSnapshot should be loaded with the same view as view parameter. For example,

View view = metadata.getViewRepository().findView(metaClass, "view");
Entity entity = em.find(javaClass, id, view);
EntitySnapshot entitySnapshot = entitySnapshotService.createSnapshot(entity, view);

Subbotin Andrey