createPartition(): Integer64;
The createPartition method of the Class class creates a new empty database partition and returns the partition identifier.
The createPartition operation is audited within a database transaction ensuring it is atomic and recoverable. Multiple related createPartition operations can be made atomic by containing them in the same database transaction. For example, if related classes such as Order and OrderItem are both partitioned, instance creation for both of them can be switched to a new current partition within the same database transaction.
A number of related createPartition operations can be made atomic by containing them in the same database transaction, as shown in the following example.
// execute just before midnight at end of current period beginTransaction; Order.createPartition; OrderItem.createPartition; // execute just after midnight at start of next period commitTransaction;
An exception is raised if the database file is locked for reorganization or if the file is not partitioned.
The following restrictions apply to the use of the createPartition method.
Partitions can only be created within a transaction
No other partition creation operation can be in progress
Persistent objects cannot be created or updated in the transaction that creates a partition
Persistent objects cannot be created in a partitioned file by any user while a new partition for that file is being created
For a production application, developers should implement a synchronization mechanism to prevent the creation of objects stored in a partitioned file while a new partition is created.