Given:
@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;
}
}
@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:
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(TestEmbeddable.class)
public abstract class TestEmbeddable_ {
public static volatile MapAttribute<TestEmbeddable, String, Integer> map;
}
instaed of
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(TestEmbeddable.class)
public abstract class TestEmbeddable_ {
public static volatile SingularAttribute<TestEmbeddable, Integer> defaultValue;
}
|