12 Haziran 2018 Salı

JPA @Access Anotasyonu

AccessType.FIELD
Şöyle yaparız.
@Entity
@Access(AccessType.FIELD)
class Employee {
  ...
}
AccessType.PROPERTY
Elimizde şöyle bir kod olsun
public class Bookmark {
  public boolean isIsPrivate() {
    ...
  }

  public void setIsPrivate(boolean newIsPrivate) {
    ...
    }
  ...
}
Şöyle yaparız.
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.1"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm 
                        http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd">

<persistence-unit-metadata>
    <xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.ogm.backendtck.type.ogmemf.impl</package>
...
<entity class="Bookmark" access="PROPERTY">
    <attributes>
        <basic name="isPrivate"/>
    </attributes>
</entity>
</entity-mappings>

Hiç yorum yok:

Yorum Gönder