diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-08-14 09:37:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-25 06:39:57 +0200 |
commit | 8d4d2568f356cb9beb1553bf58ad69c1c800b996 (patch) | |
tree | d6466f2dec931669405b38a6cf47e8bb0998a4fd /odb/database.hxx | |
parent | 46f28dcdf5a72ed430486b562213ad147b65526a (diff) |
Implement bulk database operation support for Oracle and SQL Server
Diffstat (limited to 'odb/database.hxx')
-rw-r--r-- | odb/database.hxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/odb/database.hxx b/odb/database.hxx index 1f56b7f..0de867f 100644 --- a/odb/database.hxx +++ b/odb/database.hxx @@ -33,6 +33,7 @@ #include <odb/details/mutex.hxx> #include <odb/details/c-string.hxx> #include <odb/details/function-wrapper.hxx> +#include <odb/details/meta/answer.hxx> namespace odb { @@ -55,6 +56,10 @@ namespace odb template <typename T> typename object_traits<T>::id_type + persist (const T& object); + + template <typename T> + typename object_traits<T>::id_type persist (T* obj_ptr); template <typename T, template <typename> class P> @@ -77,6 +82,13 @@ namespace odb typename object_traits<T>::id_type persist (const typename object_traits<T>::pointer_type& obj_ptr); + // Bulk persist. Can be a range of references or pointers (including + // smart pointers) to objects. + // + template <typename I> + void + persist (I begin, I end, bool continue_failed = true); + // Load an object. Throw object_not_persistent if not found. // template <typename T> @@ -163,6 +175,13 @@ namespace odb void update (const typename object_traits<T>::pointer_type& obj_ptr); + // Bulk update. Can be a range of references or pointers (including + // smart pointers) to objects. + // + template <typename I> + void + update (I begin, I end, bool continue_failed = true); + // Update a section of an object. Throws section_not_loaded exception // if section is not loaded. Note also that this function does not // clear the changed flag if it is set. @@ -206,6 +225,19 @@ namespace odb void erase (const typename object_traits<T>::pointer_type& obj_ptr); + // Bulk erase. + // + template <typename T, typename I> + void + erase (I id_begin, I id_end, bool continue_failed = true); + + // Can be a range of references or pointers (including smart pointers) + // to objects. + // + template <typename I> + void + erase (I obj_begin, I obj_end, bool continue_failed = true); + // Erase multiple objects matching a query predicate. // template <typename T> @@ -489,6 +521,18 @@ namespace odb typename object_traits<T>::id_type persist_ (const typename object_traits<T>::pointer_type&); + template <typename I, database_id DB> + void + persist_ (I, I, bool); + + template <typename I, typename T, database_id DB> + void + persist_ (I, I, bool, details::meta::no ptr); + + template <typename I, typename T, database_id DB> + void + persist_ (I, I, bool, details::meta::yes ptr); + template <typename T, database_id DB> typename object_traits<T>::pointer_type load_ (const typename object_traits<T>::id_type&); @@ -521,6 +565,10 @@ namespace odb void update_ (const typename object_traits<T>::pointer_type&); + template <typename I, database_id DB> + void + update_ (I, I, bool); + template <typename T, database_id DB> void update_ (const T&, const section&); @@ -537,6 +585,14 @@ namespace odb void erase_ (const typename object_traits<T>::pointer_type&); + template <typename I, typename T, database_id DB> + void + erase_id_ (I, I, bool); + + template <typename I, database_id DB> + void + erase_object_ (I, I, bool); + template <typename T, database_id DB, typename Q> typename object_traits<T>::pointer_type query_one_ (const Q&); |