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

EntityDefinition ignored when it's a shallow reference #1327

Closed
cberes opened this issue Oct 9, 2023 · 2 comments
Closed

EntityDefinition ignored when it's a shallow reference #1327

cberes opened this issue Oct 9, 2023 · 2 comments
Labels

Comments

@cberes
Copy link
Contributor

cberes commented Oct 9, 2023

When using EntityDefinitionBuilder.withShallowProperties, registering an EntityDefinition can cause subsequent EntityDefinitions to be ignored.

For example, say I have 2 classes, where one class has a shallow reference to the other.

class ValueObjectHolder {
    @Id int id
    Set<SetValueObject> valueObjects
}

class EntityHolder {
    @Id int id
    ValueObjectHolder valueObjectHolder
}

and I register the classes in this order

javers()
  .registerEntity(EntityDefinitionBuilder
          .entityDefinition(EntityHolder.class)
          .withIdPropertyName('id')
          .withIncludedProperties(['id', 'valueObjectHolder'])
          .withShallowProperties(['valueObjectHolder'])
          .build())
  .registerEntity(EntityDefinitionBuilder
          .entityDefinition(ValueObjectHolder.class)
          .withIdPropertyName('id')
          .withIncludedProperties(['id', 'valueObjects'])
          .build())
  .build()

The entity definition for ValueObjectHolder will be ignored. Any type name or properties I set for ValueObjectHolder will not be used.

It seems to be related to the shallow reference in EntityHolder. If I omit the call to withShallowProperties, the entity definitions are registered as expected.

Steps To Reproduce

I have a PR with a failing test. The tests are in org/javers/core/JaversDiffE2ETest.groovy. There are 2 tests:

  • should use entity definition for entity that is not a shallow reference passes; does not use withShallowProperties
  • should use entity definition for entity that is a shallow reference fails; same as above but it uses withShallowProperties

Javers' Version
7.3.2+

@bartoszwalacik
Copy link
Member

@cberes thanks for a good bug report

@bartoszwalacik
Copy link
Member

Fixed in 7.3.4

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