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
Specify ignored properties without annotations #94
Comments
I can see two ways for solving this problem. Lets say we have an Entity
One way is to register a type as ignored. All properties with that type in all classes would be ignored:
Second way (fine grained), register concrete property as ignored:
Second approach gives you full control but more configuration. I think that first approach would be better (less and type safe configuration) |
I think I would argue the second solution is superior. What if my class had 2 properties that returned the same entity. One I want to track, the other I did not. Your first solution would not solve that while the second one would. |
IgnoringPropertiesWithoutAnnTest
Hi Chuck, usage example (Spock):
|
Great. I'll run some tests this week. |
I just ran some tests are everything looks good from my end. One suggestion I would have is that there are currently 2 versions of registerEntity: public JaversBuilder registerEntity(Class<?> entityClass);
public JaversBuilder registerEntity(Class<?> entityClass, String idPropertyName, List<String> ignoredProperties); If I want to register an entity but don't care about ignored properties, I have to pass null as the third parameter. Seems like an easy call through to add public JaversBuilder registerEntity(Class<?> entityClass, String idPropertyName); That is a very minor nitpick and it works fine as it is. I did come across an issue/question about comparisons, but since this issue seems to be complete, I will option another issue for that. Thanks again. |
#94 Specify ignored properties without annotations
Interesting, we had similar doubts on Code Review, You are right, passing null as an argument is not nice. I've changed the API to:
and EntityDefinition has constructors for both cases (with and without ignored properties) I've just pushed new 1.0.6-SNAPSHOT to Sonatype, check it out. |
Sounds like a good plan, but the SNAPSHOT has that second registerEntity method as private: private JaversBuilder registerEntity(EntityDefinition entityDefinition) {
clientsClassDefinitions.add(entityDefinition);
return this;
} |
looks like you have a stale snapshot, nevermind, I've just released 1.0.6 to sonatype, tomorrow morning it will be in maven central |
Hi! First of all, thanks for this feature, it really helped! I found this weird behavior, possibly a bug, when ignoring properties of a super class. class abstract A {
private final String irrelevantString;
private final String string;
}
class B extends A {
private final String irrelevantString;
} Ignoring as new ValueObjectDefinition(B.class, Arrays.asList("irrelevantString")) works as expected, ignoring the property in the derived class. new ValueObjectDefinition(A.class, Arrays.asList("irrelevantString")) doesn't work at all. Another thing, and this is more annoying, is that when there isn't such name conflict between super and derived classes you still cannot ignore super class property. new ValueObjectDefinition(B.class, Arrays.asList("irrelevantString"))
new ValueObjectDefinition(C.class, Arrays.asList("irrelevantString"))
new ValueObjectDefinition(D.class, Arrays.asList("irrelevantString"))
// etc
// none of B, C or D contain irrelevantString property
// yet using A.class doesn't work Should i open an issue about this? |
ok, I will check it, but please post it as a new Issue, we focus on open issues |
Hi I don't think registerIgnoredType function is present in javers-core latest release is there some other way to do this in javers-core or do I have to add other dependency? |
Currently, you can ignore properties for comparisons using the @DiffIgnore annotation. There are times when you want to track history for entities which you do not have the ability to annotate. It would be very helpful if you can programmatically give a list of properties to ignore when committing changes.
The text was updated successfully, but these errors were encountered: