Hibernate not conforming to JPA regarding @Access?

According to my JPA 2.0 book (and online documentation), I should be able to mix access to fields and properties within a single hierarchy of entities or entities. The @Access annotation in the class indicates default access. When placed on a field or property, getter @Access may indicate that the default value should be overridden for this field.

@Entity
@Access(AccessType.FIELD)
Class Foo {

  @Id
  int id;

  @Column(name = "myfield")
  String myField;

  @Column(name = "myProp")
  @Access(AccessType.PROPERTY)
  public int getMyProp () {
    return 3;
  }

  public void setMyProp (int p) {
    // do nothing
  }
}

This class should result in a table with three columns. However, it is not related to Hibernate ... the column "myProp" is not in the table, because, apparently, Hibernate takes its field with the property identifier from the object identifier and starts with it ... completely ignoring the JPA specification regarding @Access.

- -?

+3
2

( , ) , HHH-5004, , (TCK ). Hibernate ? ?

+1

. @Access (AccessType.FIELD) , int id; . xml config mixed. , , , .

3.5.3

+1

Source: https://habr.com/ru/post/1753242/


All Articles