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

How to handle removed entity field? #723

Closed
chengchen opened this issue Oct 2, 2018 · 9 comments
Closed

How to handle removed entity field? #723

chengchen opened this issue Oct 2, 2018 · 9 comments
Labels
Core Team This issue will be implemented by JaVers core team fixed

Comments

@chengchen
Copy link

Hello,

I am sorry if this question is already asked, and I did search before asking, the most relevant one I found is: #511

We are using javers to do audits in our company, and we are satisfied with it's simplicity. However, we had an issue recently regarding a simple removal of a field in an Hibernate entity. And this field itself is an entity as well. So to simplify a bit: Product entity had a field called Category, but Category has been removed completely from db as well as from the code. If I don't do any change in the javers tables, it will break simply with the exception:

org.javers.common.exception.JaversException: TYPE_NAME_NOT_FOUND: type name 'com.edgelab.marketdata.domain.Issuer' not found. If you are using @TypeName annotation, remember to register this class using JaversBuilder.withPackagesToScan(String) or JaversBuilder.scanTypeName(Class)
	at org.javers.core.metamodel.type.TypeMapperState.getClassByDuckType(TypeMapperState.java:70) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.metamodel.type.TypeMapperState.getClassByTypeName(TypeMapperState.java:42) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.metamodel.type.TypeMapper.getJaversManagedType(TypeMapper.java:168) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.json.typeadapter.commit.GlobalIdTypeAdapter.parseEntity(GlobalIdTypeAdapter.java:117) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.json.typeadapter.commit.GlobalIdTypeAdapter.parseInstanceId(GlobalIdTypeAdapter.java:59) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.json.typeadapter.commit.GlobalIdTypeAdapter.fromJson(GlobalIdTypeAdapter.java:36) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.json.typeadapter.commit.GlobalIdTypeAdapter.fromJson(GlobalIdTypeAdapter.java:15) ~[javers-core-3.11.5.jar:na]
	at org.javers.core.json.JsonConverterBuilder.lambda$registerJsonTypeAdapterForType$4(JsonConverterBuilder.java:168) ~[javers-core-3.11.5.jar:na]
....

I am wondering how should we proceed in this case without cleaning up massive amount of json snapshots? I also quickly browsed in the javers source code, I could not find a place to configure ignoring removed fields..

Could you help us with some hints? Or do you need some examples to reproduce?
Many thanks!

Chengchen

@bartoszwalacik
Copy link
Member

hi, are you using the latest version?

@chengchen
Copy link
Author

@bartoszwalacik we are using 3.11.5 but I will double check the latest one tomorrow.. Not sure if it will change anything though.

@bartoszwalacik
Copy link
Member

looks like loading snapshots for removed classes is not supported. Think about contributing a PR to solve this problem. It shouldn't be hard. I can give you some hints

@chengchen
Copy link
Author

chengchen commented Oct 3, 2018

@bartoszwalacik Sure I am willing to contribute. Please give some hints and I will do it when it's possible. Let's frame a bit the expected behaviour if it's possible. So we should just ignore the removed fields in this case? but should we display removed ones in the changes?

bartoszwalacik added a commit that referenced this issue Oct 5, 2018
@bartoszwalacik
Copy link
Member

@chengchen I have created the failing test case with issue reproduction
https://github.com/javers/javers/pull/725/files

chengchen added a commit to chengchen/javers that referenced this issue Oct 8, 2018
chengchen added a commit to chengchen/javers that referenced this issue Oct 9, 2018
@bartoszwalacik
Copy link
Member

connected with
#632

@chengchen
Copy link
Author

@bartoszwalacik I tested my patch (workaround), at least it's working for our use cases. I am able to retrieve "removed" entity snapshots and even other entities contains "removed" entity.

@bartoszwalacik bartoszwalacik added the Core Team This issue will be implemented by JaVers core team label Oct 10, 2018
bartoszwalacik added a commit that referenced this issue Oct 11, 2018
bartoszwalacik added a commit that referenced this issue Oct 11, 2018
bartoszwalacik added a commit that referenced this issue Oct 11, 2018
@bartoszwalacik
Copy link
Member

to be released in 3.11.7

@bartoszwalacik
Copy link
Member

released in 3.11.7

bartoszwalacik added a commit that referenced this issue Oct 16, 2018
bartoszwalacik added a commit that referenced this issue Oct 17, 2018
bartoszwalacik added a commit that referenced this issue Oct 18, 2018
bartoszwalacik added a commit that referenced this issue Oct 18, 2018
bartoszwalacik added a commit that referenced this issue Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Team This issue will be implemented by JaVers core team fixed
Projects
None yet
Development

No branches or pull requests

2 participants