Skip Headers

# Configuring Method Accessing

Previous

Next

By default, TopLink uses direct access to access public attributes. Alternatively, you can use getter and setter methods to access object attributes when writing the attributes of the object to the database, or reading the attributes of the object from the database. This is known as method access.

The attribute's visibility (public, protected, private, or package visibility) and the supported version of JDK may restrict the type of access that you can use.

Using private, protected or package variable or method access requires you to enable the Java reflect security setting. This is enabled by default in most application servers (see "Security Permissions"), but may need to be enabled explicitly in certain JVM configurations. If necessary, use the `java.policy` file to grant `ReflectPermission` to the entire application or the application's code base. For example:

    grant{
         permission java.lang.reflect.ReflectPermission;
    };

Oracle recommends using direct access whenever possible to improve performance and avoid executing any application-specific behavior while building objects.

Table: Mapping Support for Method Accessing summarizes which mappings support this option.

Mapping Support for Method Accessing

Mapping | Using TopLink Workbench | Using Java
--- | --- | ---
Relational Mappings |  |
Object-Relational Mappings |  |
EIS Mappings |  |
XML Mappings |  |

For information on configuring method accessing at the project level, see "Configuring Mapped Field Access at the Project Level".