FindShadows() with withChildValueObjects and withScopeDeepPlus returns wrong number of nested collection child
See original GitHub issueI don’t understand why shadows return the wrong amount of collection child.
basically here’s the code :
Role roleAdmin = new Role("ADMIN");
roleAdmin.setPermissions(Lists.newArrayList(permissionReadUser, permissionViewUser, permissionCountUser, permissionExistsUser, permissionCreateUser));
roleAdmin = roleRepository.save(roleAdmin); // First version of role admin (5 permissions)
roleAdmin.setDescription("Admin role :D");
roleAdmin = roleRepository.save(roleAdmin); // Second version of role admin (5 permissions + description)
roleAdmin.getPermissions().add(permissionUpdateUser);
roleAdmin.getPermissions().add(permissionDisableUser);
roleAdmin.getPermissions().add(permissionDeleteUser);
roleAdmin = roleRepository.save(roleAdmin); // Third version of role admin (8 permissions + description)
So technically, on version 1, I would have : 5 Permissions, no description on version 2, I would have : 5 Permissions, with description on version 3, I would have : 8 Permissions, with description
However, when I query the shadows, this is the result (from logs):
JqlQuery jqlQuery = QueryBuilder.byInstanceId(roleAdmin.getId(), Role.class)
.withChildValueObjects()
.withScopeDeepPlus()
.build();
List<Shadow<Role>> shadows = javers.findShadows(jqlQuery);
shadows.forEach(e -> {
System.out.println(e.get());
System.out.println("SNAPSHOT roleAdmin permission size : " + e.get().getPermissions().size());
});
// VERSION 3
Role{permissions=[READ_USER, VIEW_USER, COUNT_USER, EXISTS_USER, CREATE_USER, UPDATE_USER, DISABLE_USER, DELETE_USER], name='ADMIN', description='Admin role :D'}
SNAPSHOT roleAdmin permission size : 8
// VERSION 2
Role{permissions=[READ_USER, VIEW_USER], name='ADMIN', description='Admin role :D'}
SNAPSHOT roleAdmin permission size : 2
// VERSION 1
Role{permissions=[], name='ADMIN', description='null'}
SNAPSHOT roleAdmin permission size : 0
The last version seems to be fine, however, the other 2 are not.
You can find my repository here : https://github.com/philippeboyd/javers-issue-managed-type
make sure to checkout branch shadow_bug
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Register object as Entity and as ValueObject in Javers
When I update my child entity I do it from parent repository. ... I tried it many times and find out that it...
Read more >JQL (JaVers Query Language) examples
findShadows() — the limit is applied to Shadows, it limits the size of the returned list. The underlying Snapshots query uses its own...
Read more >QueryBuilder (javers-core 5.8.5 API) - javadoc.io
Limits number of Snapshots to be fetched from JaversRepository in a single query, ... Only for Snapshot and Changes queries, see withChildValueObjects().
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

looks like I need to improve the docs:) I’m working on better logging (kind of a profiler for Shadow queries). It will help in cases like this, stay tuned
see changes in 3.7.5 https://javers.org/release-notes