question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FindShadows() with withChildValueObjects and withScopeDeepPlus returns wrong number of nested collection child

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bartoszwalacikcommented, Nov 28, 2017

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

0reactions
bartoszwalacikcommented, Dec 2, 2017

see changes in 3.7.5 https://javers.org/release-notes

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found