Use @VirtualAccessMethods
to specify that a specific class contains virtual methods.
Table 2-79 describes this annotation's elements.
Table 2-79 @VirtualAccessMethods Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Optional) Name of the If |
|
set |
(Optional) Name of the If |
|
Use the @VirtualAccessMethods
annotation to define access methods for mappings with in which accessType
=VIRTUAL.
Table 2-79 shows an entity using property access.
Example 2-126 Using @VirtualAccessMethods Annotation
@Entity
@VirtualAccessMethods
public class Customer{
@Id
private int id;
...
@Transient
private Map<String, Object> extensions;
public <T> T get(String name) {
return (T) extensions.get(name);
}
public Object set(String name, Object value) {
return extensions.put(name, value);
}
In addition to using the @VirtualAccessMethods
annotation, you can use the <access>
and <access-method>
elements in your eclipselink-orm.xml
file, as shown in Example 2-127.
Example 2-127 Using <access> and <access-methods> XML
<access>VIRTUAL</access><access-methods get-method="get" set-method="set"/>@Entity
For more information, see:
"Making JPA Entities and JAXB Beans Extensible" in Solutions Guide for Oracle TopLink