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

registerEntity ignored when @Id is also defined #142

Closed
erikgollot opened this issue Apr 27, 2015 · 15 comments
Closed

registerEntity ignored when @Id is also defined #142

erikgollot opened this issue Apr 27, 2015 · 15 comments

Comments

@erikgollot
Copy link

My problem is that I need to store the two versions of an Entity. So each one has a specific value for its @id field. The real identity of my entities is the field businessIdentity. So I tried to register my entities with the following code

EntityDefinition def = new EntityDefinition(PersistentEntity.class,"businessIdentity");
builder.registerEntity(def);
Javers javers = builder.build();

The problem is that Javers (I look with the debugger), always take my @id field as the object identity.

Do I miss something ?

@bartoszwalacik
Copy link
Member

registerEntity(EntityDefinition) should have priority over annotation scanner. You mean that now we have diffrent situation, so @id annotation overriders registerEntity(EntityDefinition)?

@erikgollot
Copy link
Author

Yes it seems that @id has the priority. I tried to had @ diffignore near @id and javers says that my object des not have any identity...even if previously i've used registerEntity.

@bartoszwalacik
Copy link
Member

Right, I'll check this out

@erikgollot
Copy link
Author

Thanks !!

Let me know

@bartoszwalacik
Copy link
Member

well, we have a test showing that Id property name given in EntityDefinition overrides
@id annotation

https://github.com/javers/javers/blob/b523a05b64b86631ab9fd01da4616f6518590087/javers-core/src/test/groovy/org/javers/core/metamodel/clazz/EntityFactoryIdTest.groovy
see def "should use custom id property when given"()

could you come up with a failing test, which shows that in your case you have the opposite behaviour?
it could be done in your fork of javers

@erikgollot
Copy link
Author

Ok i will do that tomorrow...I'm in France and it 11:30 pm 

Envoyé depuis Yahoo Mail pour Android

De:"Bartosz Walacik" notifications@github.com
Date:Mer j Avr PM à 23:22
Objet:Re: [javers] registerEntity ignored when @id is also defined (#142)

well, we have a test showing that Id property name given in EntityDefinition overrides
@id annotation

https://github.com/javers/javers/blob/b523a05b64b86631ab9fd01da4616f6518590087/javers-core/src/test/groovy/org/javers/core/metamodel/clazz/EntityFactoryIdTest.groovy
see def "should use custom id property when given"()

could you come up with a failing test, which shows that in your case you have the opposite behaviour?
it could be done in your fork of javers


Reply to this email directly or view it on GitHub.

@erikgollot
Copy link
Author

In the following clone of javers on my GitHub : erikgollot/javers
|   |
|   | |   |   |   |   |   |
| erikgollot/javersjavers - JaVers is a tool for auditing object-oriented data |
| |
| Afficher sur githu... | Aperçu par Yahoo |
| |
|   |

You will find a test : org.javers.core.examples.ShouldUseRegisterAndNotIdObjectTest that fail.
In fact, it fail if I instantiate a child class of my base class ShouldUseRegisterAndNotIdObject. If the base class is not abstract and if I instantiate this class, no problem.So the problem comes with inheritance
De : Bartosz Walacik notifications@github.com
À : javers/javers javers@noreply.github.com
Cc : erikgollot erik_gollot@yahoo.fr
Envoyé le : Mercredi 29 avril 2015 23h22
Objet : Re: [javers] registerEntity ignored when @id is also defined (#142)

well, we have a test showing that Id property name given in EntityDefinition overrides
@id annotationhttps://github.com/javers/javers/blob/b523a05b64b86631ab9fd01da4616f6518590087/javers-core/src/test/groovy/org/javers/core/metamodel/clazz/EntityFactoryIdTest.groovy
see def "should use custom id property when given"()could you come up with a failing test, which shows that in your case you have the opposite behaviour?
it could be done in your fork of javers—
Reply to this email directly or view it on GitHub.

@bartoszwalacik
Copy link
Member

@erikgollot, well, i cant see any commit at your fork. Where is your failing test?

@erikgollot
Copy link
Author

Oh sorry, i probably forgot to push.

I've made a test that shows the problem when we've inheritance. It works if not.

Envoyé depuis Yahoo Mail pour Android

De:"Bartosz Walacik" notifications@github.com
Date:Ven j Mai PM à 22:23
Objet:Re: [javers] registerEntity ignored when @id is also defined (#142)

@erikgollot, well, i cant see any commit at your fork. Where is your failing test?


Reply to this email directly or view it on GitHub.

@erikgollot
Copy link
Author

I cannot push now, i dont have access to my computer. I will do it asap

Envoyé depuis Yahoo Mail pour Android

De:"Bartosz Walacik" notifications@github.com
Date:Ven j Mai PM à 22:23
Objet:Re: [javers] registerEntity ignored when @id is also defined (#142)

@erikgollot, well, i cant see any commit at your fork. Where is your failing test?


Reply to this email directly or view it on GitHub.

@erikgollot
Copy link
Author

You can have a look at https://github.com/erikgollot/javers/tree/check-register-definition-priority/javers-core/src/test/java/org/javers/core/examples
Class ShouldUseRegisterAndNotIdObjectTest.java

@bartoszwalacik
Copy link
Member

ok, but why have you closed the issue?

@erikgollot
Copy link
Author

I will check, I don't know why maybe a mistake

Envoyé depuis Yahoo Mail pour Android

De:"Bartosz Walacik" notifications@github.com
Date:Lun j Mai PM à 22:43
Objet:Re: [javers] registerEntity ignored when @id is also defined (#142)

ok, but why have you closed the issue?


Reply to this email directly or view it on GitHub.

@erikgollot erikgollot reopened this May 26, 2015
@bartoszwalacik
Copy link
Member

ok, now I can see the issue

@bartoszwalacik
Copy link
Member

fixed in vesrion 1.2.8
http://javers.org/documentation/features/#release-notes

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

No branches or pull requests

2 participants