Use @ValuePartitioning
to partition access to a database cluster by a field value from the object (such as the object's location or tenant). Each value is assigned a specific server. All write or read request for object's with that value are sent to the server. If a query does not include the field as a parameter, then it can either be sent to all server's and unioned, or left to the session's default behavior.
Annotation Elements
Table 2-77 describes this annotation's elements.
Table 2-77 @ValuePartitioning Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Required) Name of the partition policy. Names must be unique for the persistence unit. |
|
|
(Required) The database column or query parameter to partition queries by This is the table column name, not the class attribute name. The column value must be included in the query and should normally be part of the object's ID. This can also be the name of a query parameter. If a query does not contain the field the query will not be partitioned. |
|
|
(Required) Store the value partitions. Each partition maps a value to a |
|
|
(Optional) The default connection pool is used for any unmapped values |
|
|
(Optional) The |
|
|
(Optional) Defines if queries that do not contain the partition field should be sent to every database and have the result unioned. |
|
Usage
Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit. Partition policies are globally named to allow reuse, the partitioning policy must also be set using the @Partitioned
annotation to be used.
The persistence unit properties support adding named connection pools in addition to the existing configuration for read/write/sequence. A named connection pool must be defined for each node in the database cluster.
If a transaction modifies data from multiple partitions, you should use JTA ensure proper two-phase commit of the data. You can also configure an exclusive connection in the EntityManager to ensure that only a single node is used for a single transaction.
Examples
See "Using Partitioning" for an example of partitioning with EclipseLink.
See Also
For more information, see: