You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with Bean Mapping Style due to Type Erasure #457
When using Bean MappingStyle (using @id on getters), an issue is being encountered with the use of the @id annotation on an extended generic method. This results in an ENTITY_WITHOUT_ID Exception ("Class '%s' mapped as Entity has no Id property. Use @id annotation to mark unique and not-null Entity identifier") being thrown.
This can be easily replicated when we have an abstract Parent class that defines a getter method which is overridden by a child class getter annotated with @id. Example:
public abstract class AbstractEntity<ID extends Serializable> {
public abstract ID getId();
}
and child:
public class Entity extends AbstractEntity<Long> {
private Long id;
public Entity(Long id) {
this.id = id;
}
@Id
@Override
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
public java.io.Serializable org.javers.core.model.Entity.getId(); // bridge method
public java.lang.long org.javers.core.model.Entity.getId(); // our method with @Id annotation
public java.lang.long org.javers.core.model.Entity.setId();
In JaversMethodFactory.getAllMethods(), sometimes this method processes the 'bridge' method first, before our method, and this results in our method to be skipped since the logic filters inheritance duplicates. A suggested solution is to skip the bridge method, thus our method can be added.
PR with failing test case and proposed solution will be pushed soon.
Activity
ianagius commentedon Nov 15, 2016
created the following pull request #458
bartoszwalacik commentedon Nov 16, 2016
@ianagius thanks for excelent issue description and the PR. I'll try to merge this evening
#457 test fixes
ianagius commentedon Nov 16, 2016
cheers
bartoszwalacik commentedon Nov 16, 2016
merged, your fix will be released tomorrow
bartoszwalacik commentedon Nov 17, 2016
fix released in 2.7.1