1C:Enteprise provides tools for serializing many value types (that is, converting them to a format that allows saving and restoring them). In 1C:Enterprise script documentation, serializable objects are described with the "Serializable" keyword.
Use serialization whenever you need to store or transfer values in the serialized format within a single Infobase for any reason.
This section describes regular serialization (not XML serialization). XML serialization is intended for data exchange with other 1C:Enterprise Infobases and third-party systems. The "Serializable" keyword in object descriptions is not related to XML serialization.
1C:Enterprise has several features that utilize serialization.
Saving values to files, restoring values from files
This feature includes the ValueToFile() and ValueFromFile() methods. It is mostly used for saving temporary values within a session or between sessions.
Saving values to ValueStorage objects
This feature is mostly used for recording values that do not have matching field types, such as pictures or binary data, to an Infobase. A value recorded to value storage can be compressed.
Storing user parameters between sessions
The platform uses this feature for saving report or data processor form settings. This feature also includes the SaveValue() and RestoreValue() methods. We recommend that you use these methods for saving user-specific settings. However, we recommend that you do not use these methods for saving important data because data saved this way is not included in Infobase backups. Also, this data is only saved at the end of the session and therefore can be lost in the event of abnormal session termination.
Saving values to strings, restoring values from strings
This feature includes the ValueToStringInternal() and ValueFromStringInternal() methods but we recommend that you do not use them because they were implemented for compatibility with previous platform versions. Instead, use the ValueStorage object for storing values to the database. To get a string ID of a reference value, use the UUID() method, which gets a unique reference identifier, and then converts the value it returns to a string.
If an attempt to restore a reference to an applied object is made after the corresponding metadata object is deleted, the restoration result is an Undefined value.
The 1C:Enterprise serialization format is proprietary. We recommend that you always use 1C:Enterprise tools and do not use third-party tools for restoring serialized values.
1C:Enterprise serialization uses the internal identification of value types. Identification of applied object types is based on internal IDs that are stored in metadata, therefore serialized values cannot be restored in another Infobase even if it has exactly the same metadata object names and properties.
Summing up what has been said, use serialization for storing and transferring values within a single 1C:Enterprise Infobase. Do not use it for data exchange with other Infobases or third-party systems.Next page: Specifics of database string comparison