Use @Partitioning
to configure a custom PartitioningPolicy
.
Table 2-48 describes this annotation's elements.
Table 2-48 @Partitioning Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
Name of the partition policy. Names must be unique for the persistence unit. |
|
|
(Required) Full |
Data partitioning allows for an application to scale its data across more than a single database machine. TopLink supports data partitioning at the Entity level to allow a different set of entity instances for the same class to be stored in a different physical database or different node within a database cluster. Both regular databases and clustered databases are supported. Data can be partitioned both horizontally and vertically.
Partitioning can be enabled on an entity, a relationship, a query, or a persistence unit.
Example 2-89 shows a custom partitioning policy.
Example 2-89 Using @Partitioning Annotation
@Entity
@Partitioning(name="order", partitioningClass=OrderPartitioningPolicy.class)
@public class Order {
...
}
public class OrderPartitioningPolicy extends PartitioningPolicy {
public List<Accessor> getConnectionsForQuery(AbstractSession session, DatabaseQuery query, AbstractRecord arguments) {
List<Accessor> accessors = new ArrayList<Accessor>(1);
accessors.add(getAccessor(ACMEPool.leastBusy(), session, query, false));
return accessors;
}
}
For more information, see: