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

Comments

Projects
None yet
2 participants
@chengchen

chengchen commented Oct 2, 2018

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

This comment has been minimized.

Member

bartoszwalacik commented Oct 2, 2018

hi, are you using the latest version?

@chengchen

This comment has been minimized.

chengchen commented Oct 2, 2018

@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

This comment has been minimized.

Member

bartoszwalacik commented Oct 3, 2018

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

This comment has been minimized.

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

#723
issue reproduction
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 5, 2018

@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

This comment has been minimized.

Member

bartoszwalacik commented Oct 10, 2018

connected with
#632

@chengchen

This comment has been minimized.

chengchen commented Oct 10, 2018

@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 added a commit that referenced this issue Oct 11, 2018

#723
issue fix

bartoszwalacik added a commit that referenced this issue Oct 11, 2018

#723
imports

bartoszwalacik added a commit that referenced this issue Oct 11, 2018

#723
lazy eval

bartoszwalacik added a commit that referenced this issue Oct 11, 2018

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 11, 2018

to be released in 3.11.7

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Oct 11, 2018

released in 3.11.7

bartoszwalacik added a commit that referenced this issue Oct 16, 2018

#723
query for optional

bartoszwalacik added a commit that referenced this issue Oct 17, 2018

#723
get latest for many

bartoszwalacik added a commit that referenced this issue Oct 18, 2018

#723
perf test ignored

bartoszwalacik added a commit that referenced this issue Oct 18, 2018

#723
more javers queries

bartoszwalacik added a commit that referenced this issue Oct 19, 2018

#723
partial commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment