We're updating the issue view to help you get more done. 

Metamodel generation uses wrong access type for embeddables

Description

Given:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 @Entity @Access(AccessType.FIELD) public class TestEntity { @Id private long id; @Embedded private TestEmbeddable embeddable; public long getId() { return id; } public void setId(long id) { this.id = id; } public TestEmbeddable getEmbeddable() { return embeddable; } public void setEmbeddable(TestEmbeddable embeddable) { this.embeddable = embeddable; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 @Embeddable @Access(AccessType.PROPERTY) public class TestEmbeddable { private final Map<String, Integer> map; public TestEmbeddable() { map = new HashMap<>(); } public int getDefaultValue() { return map.get(null); } public void setDefaultValue(int value) { map.put(null, value); } }

Hibernate metamodel generator fails to use the correct access type for the embeddable. Access type is normally being inherited from entity type, if it is not "overriden" on the embeddable type itself. If one specifies a dedicated access type on the embeddable type, this information are used during O/R mapping, but not during metamodel generation, so the outcome of the above mentioned is:

1 2 3 4 5 6 7 @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(TestEmbeddable.class) public abstract class TestEmbeddable_ { public static volatile MapAttribute<TestEmbeddable, String, Integer> map; }


instaed of

1 2 3 4 5 6 7 @Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor") @StaticMetamodel(TestEmbeddable.class) public abstract class TestEmbeddable_ { public static volatile SingularAttribute<TestEmbeddable, Integer> defaultValue; }

Environment

None

Status

Assignee

Unassigned

Reporter

Sven Linstaedt

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.8

Priority

Major