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

Comments

Projects
None yet
2 participants
@erikgollot

erikgollot commented Apr 27, 2015

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

This comment has been minimized.

Member

bartoszwalacik commented Apr 29, 2015

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

@erikgollot

This comment has been minimized.

erikgollot commented Apr 29, 2015

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

This comment has been minimized.

Member

bartoszwalacik commented Apr 29, 2015

Right, I'll check this out

@erikgollot

This comment has been minimized.

erikgollot commented Apr 29, 2015

Thanks !!

Let me know

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Apr 29, 2015

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

This comment has been minimized.

erikgollot commented Apr 29, 2015

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

This comment has been minimized.

erikgollot commented Apr 30, 2015

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

This comment has been minimized.

Member

bartoszwalacik commented May 15, 2015

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

@erikgollot

This comment has been minimized.

erikgollot commented May 16, 2015

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

This comment has been minimized.

erikgollot commented May 16, 2015

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

This comment has been minimized.

erikgollot commented May 24, 2015

@erikgollot erikgollot closed this May 24, 2015

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented May 25, 2015

ok, but why have you closed the issue?

@erikgollot

This comment has been minimized.

erikgollot commented May 26, 2015

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

This comment has been minimized.

Member

bartoszwalacik commented May 29, 2015

ok, now I can see the issue

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented May 31, 2015

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