From 8e046e3ea7e88f872205c2b65cb7f9b86aaabd93 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov However, a value type that can be used as an object id has a number
of restrictions. Such a value type cannot have container, object
pointer, or read-only data members. It also must be
- default-constructible and implement the less-than comparison operator
- (12.1.7 callback
12.1.8 schema
+ 12.1.9 polymorphic
@@ -535,6 +536,7 @@ for consistency.
12.1.10 session
12.5.1 pointer
12.5.2 table
+ 12.5.3 schema
@@ -6090,8 +6092,10 @@ class person
12.5.4 session
operator<
).operator<
).
Similarly, if we enable or disable session support + (Chapter 10, "Session") for the root class, then + the ODB compiler will automatically enable or disable it for all + the derived classes.
+For polymorphic persistent classes, all the database operations can be performed on objects with different static and dynamic types. Similarly, operations that load persistent objects from the @@ -8258,6 +8267,50 @@ struct employee_name object cache. In future versions it will provide additional functionality, such as automatic object state change tracking.
+Session support is optional and can be enabled or disabled on the
+ per object basis using the db session
pragma, for
+ example:
+#pragma db object session +class person +{ + ... +}; ++ +
We can also enable or disable session support for a group of + objects at the namespace level:
+ ++#pragma db namespace session +namespace accounting +{ + #pragma db object // Session support is enabled. + class employee + { + ... + }; + + #pragma db object session(false) // Session support is disabled. + class employer + { + ... + }; +} ++ +
Finally, we can pass the --generate-session
ODB compiler
+ option to enable session support by default. With this option session
+ support will be enabled for all the persistent classes except those
+ for which it was explicitly disabled using the
+ db session
. An alternative to this method with the
+ same effect is to enable session support for the global namespace:
+#pragma db namespace() session ++
Each thread of execution in an application can have only one active
session at a time. A session is started by creating an instance of
the odb::session
class and is automatically terminated
@@ -8374,8 +8427,8 @@ namespace odb
A session is an object cache. Every time an object is made persistent
- by calling the database::persist()
function
+
A session is an object cache. Every time a session-enabled object is
+ made persistent by calling the database::persist()
function
(Section 3.7, "Making Objects Persistent"), loaded
by calling the database::load()
or database::find()
function (Section 3.8, "Loading Persistent Objects"),
@@ -8991,6 +9044,12 @@ class person
session
table
session
The session
specifier specifies whether to enable
+ session support for a persistent class. For example:
+#pragma db object session // Enable. +class person +{ + ... +}; + +#pragma db object session(true) // Enable. +class employee +{ + ... +}; + +#pragma db object session(false) // Disable. +class employer +{ + ... +}; ++ +
Session support is disabled by default unless the
+ --generate-session
ODB compiler option is specified
+ or session support is enabled at the namespace level
+ (Section 12.5.4, "session
").
+ For more information on sessions, refer to Chapter
+ 10, "Session".
A pragma with the view
qualifier declares a C++ class
@@ -11380,6 +11471,12 @@ namespace test
session
pointer
schema
".
+ session
The session
specifier specifies whether to enable
+ session support for persistent classes inside a namespace. For
+ example:
+#pragma db namespace session +namespace hr +{ + #pragma db object // Enabled. + class employee + { + ... + }; + + #pragma db object session(false) // Disabled. + class employer + { + ... + }; +} ++ +
Session support is disabled by default unless the
+ --generate-session
ODB compiler option is specified.
+ Session support specified at the namespace level can be overridden
+ on the per object basis (Section 12.1.10,
+ "session
"). For more information on sessions,
+ refer to Chapter 10, "Session".
When a C++ header file defining persistent classes and containing -- cgit v1.1