Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JaversException: MANAGED_CLASS_MAPPING_ERROR: given javaClass 'class java.util.LinkedHashSet' is mapped to CollectionType, expected ManagedType #1314

Closed
cberes opened this issue Jul 31, 2023 · 2 comments
Labels

Comments

@cberes
Copy link
Contributor

cberes commented Jul 31, 2023

Hi there, using 7.3.0 when I commit an entity that has shallow references properties (configured via EntityDefinitionBuilder) I get this error:

org.javers.common.exception.JaversException: MANAGED_CLASS_MAPPING_ERROR: given javaClass 'class java.util.LinkedHashSet' is mapped to CollectionType, expected ManagedType

The class in question looks like this

class Entity1 {
  Set<Entity2> entity2s;
}

When I check the type mapping, the Set field is mapped to ValueObjectType when it should be CollectionType.

Steps To Reproduce

I will have a PR with some tests ready in a moment. I'm trying to debug it now but I haven't nailed down a solution. It seems that in JaversProperty.isShallowReference(), the call to getType() causes Set to be registered as a ValueObjectType. I used only Set in the test but I believe other collection types such as List are affected.

The specific failing test is should map Set field to SetType when entity is registered with shallow properties in JaversDiffE2ETest. The tests don't do any commits. Instead they check the type mapping.

I have other tests for similar scenarios. The other tests pass, so it seems specific to the new EntityDefinitionBuilder.withShallowProperties method.

Javers' Version

7.3.x

@bartoszwalacik
Copy link
Member

@cberes thanks for reporting, I will take a look

@bartoszwalacik
Copy link
Member

fixed in 7.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants