Using the Session Session Basics Basics of Using a Session Framing out a begin / commit / rollback blockQuerying (1.x Style)Adding New or Existing ItemsFlushingUPDATE and DELETE with arbitrary WHERE clauseRolling Back Session Frequently Asked Questions When do I construct a , when do I commit it, and when do I close it?How can I get the Session for a certain object? State Management Getting the Current State of an Object Session Referencing Behavior Merge Tips Refreshing / Expiring When to Expire or Refresh delete Using foreign key ON DELETE cascade with ORM relationships delete-orphanrefresh-expireControlling Cascade on Backrefs Transactions and Connection Management Using SAVEPOINTExplicit BeginSetting Transaction Isolation Levels / DBAPI AUTOCOMMIT Joining a Session into an External Transaction (such as for test suites) Embedding SQL Insert/Update Expressions into a FlushForcing NULL on a column with a default Case 1: non primary key, RETURNING or equivalent is supportedCase 3: primary key, RETURNING or equivalent is supported Partitioning Strategies (e.g. multiple database backends per Session) Coordination of Transactions for a multiple-engine SessionHorizontal Partitioning Comparison to Core Insert / Update Constructs Contextual/Thread-local Sessions Thread-Local ScopeUsing Custom Created Scopes Tracking queries, object and Session Changes with Events Basic Query InterceptionRe-Executing Statements Object Lifecycle Events Transient to PendingPending to TransientPersistent to TransientDeleted to DetachedDetached to Persistent Transaction Events Session API Attribute and State Management Utilities