JPA XML 描述符文件中的访问策略是如何确定的?
How is access strategy determined in a JPA XML descriptor file?
如果在class中没有指定注释,在XML描述符文件中指定了所有元数据,那么访问策略(field/method)是如何确定的?
来自《Pro JPA 2》一书:
The access element that is defined in the persistence-unit-defaults
section is used to set the access type for all the managed classes in
the persistence unit that have XML entries but are not annotated. Its
value can be either “FIELD” or “PROPERTY”
<entity-mappings>
<persistence-unit-metadata>
<persistence-unit-defaults>
<access>PROPERTY</access>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
可以通过任何实体、映射超类或可嵌入元素上的访问属性覆盖默认值。
如果在class中没有指定注释,在XML描述符文件中指定了所有元数据,那么访问策略(field/method)是如何确定的?
来自《Pro JPA 2》一书:
The access element that is defined in the persistence-unit-defaults section is used to set the access type for all the managed classes in the persistence unit that have XML entries but are not annotated. Its value can be either “FIELD” or “PROPERTY”
<entity-mappings>
<persistence-unit-metadata>
<persistence-unit-defaults>
<access>PROPERTY</access>
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
可以通过任何实体、映射超类或可嵌入元素上的访问属性覆盖默认值。