NHibernate : NHibernate Namespace

ISession Interface

The main runtime interface between a Java application and Hibernate. This is the central API class abstracting the notion of a persistence service.

public interface ISession : IDisposable

Remarks

The lifecycle of a ISession is bounded by the beginning and end of a logical transaction. (Long transactions might span several database transactions.)

The main function of the ISession is to offer create, find and delete operations for instances of mapped entity classes. Instances may exist in one of two states: [The '' type of list has not been implemented in the ECMA stylesheet.]

Transient instances may be made persistent by calling Save(), Insert(), or Update(). Persistent instances may be made transient by calling Delete(). Any instance returned by a Find(), Iterate(), Load(), or Create method is persistent.

Save() results in an SQL INSERT, Delete() in an SQL DELETE and Update() in an SQL UPDATE. Changes to persistent instances are deteced at flush time and also result in an SQL UPDATE.

It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from an ISessionFactory.

A ISession instance is serializable if its persistent classes are serializable

A typical transaction should use the following idiom:
Example
            		ISession sess = factory.OpenSession();
            		ITransaction tx;
            		try {
            			tx = sess.BeginTransaction();
            			//do some work
            			...
            			tx.Commit();
            		} catch (Exception e) {
            			if (tx != null) tx.Rollback();
            			throw;
            		} finally {
            			sess.Close();
            		}
            	

If the ISession throws an exception, the transaction must be rolled back and the session discarded. The internal state of the ISession might not be consistent with the database after the exception occurs.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Members

Public Properties

[read-only]
Connection System.Data.IDbConnection . Gets the ADO.NET connection.
FlushMode FlushMode . Determines at which points Hibernate automatically flushes the session.
[read-only]
IsConnected bool . Is the ISession currently connected?
[read-only]
IsOpen bool . Is the ISession still open?
[read-only]
SessionFactory ISessionFactory . Get the NHibernate.ISessionFactory that created this instance.
[read-only]
Transaction ITransaction . Get the current Unit of Work and return the associated ITransaction object.

Public Methods

BeginTransaction () : ITransaction
Begin a unit of work and return the associated ITransaction object.
BeginTransaction (System.Data.IsolationLevel) : ITransaction
Begin a transaction with the specified isolationLevel
CancelQuery ()
Cancel execution of the current query.
Clear ()
Completely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open enumerables or instances of ScrollableResults.
Close () : System.Data.IDbConnection
End the ISession by disconnecting from the ADO.NET connection and cleaning up.
Contains (object) : bool
Is this instance associated with this Session?
CreateCriteria (Type) : ICriteria
Creates a new Criteria for the entity class.
CreateCriteria (Type, string) : ICriteria
Creates a new Criteria for the entity class with a specific alias
CreateFilter (object, string) : IQuery
Create a new instance of Query for the given collection and filter string
CreateMultiQuery () : IMultiQuery
Create a multi query, a query that can send several queries to the server, and return all their results in a single call.
CreateQuery (string) : IQuery
Create a new instance of Query for the given query string
CreateSQLQuery (string) : ISQLQuery
Create a new instance of NHibernate.ISQLQuery for the given SQL query string.
CreateSQLQuery (string, string, Type) : IQuery
Create a new instance of IQuery for the given SQL string.
CreateSQLQuery (string, string[], Type[]) : IQuery
Create a new instance of NHibernate.IQuery for the given SQL string.
Delete (object)
Remove a persistent instance from the datastore.
Delete (string) : int
Delete all objects returned by the query.
Delete (string, object, NHibernate.Type.IType) : int
Delete all objects returned by the query.
Delete (string, object[], NHibernate.Type.IType[]) : int
Delete all objects returned by the query.
DisableFilter (string)
Disable the named filter for the current session.
Disconnect () : System.Data.IDbConnection
Disconnect the ISession from the current ADO.NET connection.
EnableFilter (string) : IFilter
Enable the named filter for this current session.
Enumerable (string) : IEnumerable
Execute a query and return the results in an interator.
Enumerable (string, object, NHibernate.Type.IType) : IEnumerable
Execute a query and return the results in an interator, binding a value to a "?" parameter in the query string.
Enumerable (string, object[], NHibernate.Type.IType[]) : IEnumerable
Execute a query and return the results in an interator, binding the values to "?"s parameters in the query string.
Evict (object)
Remove this instance from the session cache.
Filter (object, string) : ICollection
Apply a filter to a persistent collection.
Filter (object, string, object, NHibernate.Type.IType) : ICollection
Apply a filter to a persistent collection, binding the given parameter to a "?" placeholder
Filter (object, string, object[], NHibernate.Type.IType[]) : ICollection
Apply a filter to a persistent collection, binding the given parameters to "?" placeholders.
Find (string) : IList
Execute a query
Find (string, object, NHibernate.Type.IType) : IList
Execute a query, binding a value to a "?" parameter in the query string.
Find (string, object[], NHibernate.Type.IType[]) : IList
Execute a query, binding an array of values to a "?" parameters in the query string.
Flush ()
Force the ISession to flush.
Get (Type, object) : object
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)
Get (Type, object, LockMode) : object
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. Obtain the specified lock mode if the instance exists.
Get<T> (object) : T
Strongly-typed version of ISession.Get(Type, object)
Get<T> (object, LockMode) : T
Strongly-typed version of ISession.Get(Type, object, LockMode)
GetCurrentLockMode (object) : LockMode
Determine the current lock mode of the given object
GetEnabledFilter (string) : IFilter
Retrieve a currently enabled filter by name.
GetIdentifier (object) : object
Return the identifier of an entity instance cached by the ISession
GetNamedQuery (string) : IQuery
Obtain an instance of NHibernate.IQuery for a named query string defined in the mapping file.
GetSessionImplementation () : NHibernate.Engine.ISessionImplementor
Gets the session implementation.
IsDirty () : bool
Does this ISession contain any changes which must be synchronized with the database? Would any SQL be executed if we flushed this session?
Load (object, object)
Read the persistent state associated with the given identifier into the given transient instance.
Load (Type, object) : object
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.
Load (Type, object, LockMode) : object
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode.
Load<T> (object) : T
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.
Load<T> (object, LockMode) : T
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode.
Lock (object, LockMode)
Obtain the specified lock level upon the given object.
Reconnect ()
Obtain a new ADO.NET connection.
Reconnect (System.Data.IDbConnection)
Reconnect to the given ADO.NET connection.
Refresh (object)
Re-read the state of the given instance from the underlying database.
Refresh (object, LockMode)
Re-read the state of the given instance from the underlying database, with the given LockMode.
Replicate (object, ReplicationMode)
Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session.
Save (object) : object
Persist the given transient instance, first assigning a generated identifier.
Save (object, object)
Persist the given transient instance, using the given identifier.
SaveOrUpdate (object)
Either Save() or Update() the given instance, depending upon the value of its identifier property.
SaveOrUpdateCopy (object) : object
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.
SaveOrUpdateCopy (object, object) : object
Copy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.
Update (object)
Update the persistent instance with the identifier of the given transient instance.
Update (object, object)
Update the persistent state associated with the given identifier.

Member Details

BeginTransaction Method

Begin a unit of work and return the associated ITransaction object.

public ITransaction BeginTransaction ()

Returns

A transaction instance

Remarks

If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned NHibernate.ITransaction object is determined by the property hibernate.transaction_factory

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

BeginTransaction Method

Begin a transaction with the specified isolationLevel

public ITransaction BeginTransaction (System.Data.IsolationLevel isolationLevel)

Parameters

isolationLevel
Isolation level for the new transaction

Returns

A transaction instance having the specified isolation level

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CancelQuery Method

Cancel execution of the current query.

public void CancelQuery ()

Remarks

May be called from one thread to stop execution of a query in another thread. Use with care!

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Clear Method

Completely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open enumerables or instances of ScrollableResults.

public void Clear ()

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Close Method

End the ISession by disconnecting from the ADO.NET connection and cleaning up.

Returns

The connection provided by the application or null

Remarks

It is not strictly necessary to Close() the ISession but you must at least Disconnect() it.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Connection Property

Gets the ADO.NET connection.

public System.Data.IDbConnection Connection { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Applications are responsible for calling commit/rollback upon the connection before closing the ISession.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Contains Method

Is this instance associated with this Session?

public bool Contains (object obj)

Parameters

obj
an instance of a persistent class

Returns

true if the given instance is associated with this Session

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateCriteria Method

Creates a new Criteria for the entity class.

public ICriteria CreateCriteria (Type persistentClass)

Parameters

persistentClass
The class to Query

Returns

An ICriteria object

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateCriteria Method

Creates a new Criteria for the entity class with a specific alias

public ICriteria CreateCriteria (Type persistentClass, string alias)

Parameters

persistentClass
The class to Query
alias
The alias of the entity

Returns

An ICriteria object

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateFilter Method

Create a new instance of Query for the given collection and filter string

public IQuery CreateFilter (object collection, string queryString)

Parameters

collection
A persistent collection
queryString
A hibernate query

Returns

A query

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateMultiQuery Method

Create a multi query, a query that can send several queries to the server, and return all their results in a single call.

public IMultiQuery CreateMultiQuery ()

Returns

An NHibernate.IMultiQuery that can return a list of all the results of all the queries. Note that each query result is itself usually a list.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateQuery Method

Create a new instance of Query for the given query string

public IQuery CreateQuery (string queryString)

Parameters

queryString
A hibernate query string

Returns

The query

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateSQLQuery Method

Create a new instance of NHibernate.ISQLQuery for the given SQL query string.

public ISQLQuery CreateSQLQuery (string queryString)

Parameters

queryString

Returns

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateSQLQuery Method

Create a new instance of IQuery for the given SQL string.

[System.Obsolete("Use CreateSQLQuery().AddEntity()")]
public IQuery CreateSQLQuery (string sql, string returnAlias, Type returnClass)

Parameters

sql
a query expressed in SQL
returnAlias
a table alias that appears inside {} in the SQL string
returnClass
the returned persistent class

Returns

An NHibernate.IQuery from the SQL string

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

CreateSQLQuery Method

Create a new instance of NHibernate.IQuery for the given SQL string.

[System.Obsolete("Use CreateSQLQuery().AddEntity()")]
public IQuery CreateSQLQuery (string sql, string[] returnAliases, Type[] returnClasses)

Parameters

sql
a query expressed in SQL
returnAliases
an array of table aliases that appear inside {} in the SQL string
returnClasses
the returned persistent classes

Returns

An NHibernate.IQuery from the SQL string

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Delete Method

Remove a persistent instance from the datastore.

public void Delete (object obj)

Parameters

obj
The instance to be removed

Remarks

The argument may be an instance associated with the receiving ISession or a transient instance with an identifier associated with existing persistent state.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Delete Method

Delete all objects returned by the query.

public int Delete (string query)

Parameters

query
The query string

Returns

Returns the number of objects deleted.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Delete Method

Delete all objects returned by the query.

public int Delete (string query, object value, NHibernate.Type.IType type)

Parameters

query
The query string
value
A value to be written to a "?" placeholer in the query
type
The hibernate type of value.

Returns

The number of instances deleted

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Delete Method

Delete all objects returned by the query.

public int Delete (string query, object[] values, NHibernate.Type.IType[] types)

Parameters

query
The query string
values
A list of values to be written to "?" placeholders in the query
types
A list of Hibernate types of the values

Returns

The number of instances deleted

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

DisableFilter Method

Disable the named filter for the current session.

public void DisableFilter (string filterName)

Parameters

filterName
The name of the filter to be disabled.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Disconnect Method

Disconnect the ISession from the current ADO.NET connection.

public System.Data.IDbConnection Disconnect ()

Returns

The connection provided by the application or null

Remarks

If the connection was obtained by Hibernate, close it or return it to the connection pool. Otherwise return it to the application. This is used by applications which require long transactions.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

EnableFilter Method

Enable the named filter for this current session.

public IFilter EnableFilter (string filterName)

Parameters

filterName
The name of the filter to be enabled.

Returns

The Filter instance representing the enabled fiter.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Enumerable Method

Execute a query and return the results in an interator.

[System.Obsolete("Use ISession.CreateQuery().Enumerable()")]
public IEnumerable Enumerable (string query)

Parameters

query
The query string

Returns

An enumerator

Remarks

If the query has multiple return values, values will be returned in an array of type object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So Enumerator() is usually a less efficient way to retrieve object than Find().

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Enumerable Method

Execute a query and return the results in an interator, binding a value to a "?" parameter in the query string.

[System.Obsolete("Use ISession.CreateQuery().SetXYZ().Enumerable()")]
public IEnumerable Enumerable (string query, object value, NHibernate.Type.IType type)

Parameters

query
The query string
value
A value to be written to a "?" placeholder in the query string
type
The hibernate type of the value

Returns

An enumerator

Remarks

If the query has multiple return values, values will be returned in an array of type object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So Enumerator() is usually a less efficient way to retrieve object than Find().

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Enumerable Method

Execute a query and return the results in an interator, binding the values to "?"s parameters in the query string.

[System.Obsolete("Use ISession.CreateQuery().SetXYZ().Enumerable()")]
public IEnumerable Enumerable (string query, object[] values, NHibernate.Type.IType[] types)

Parameters

query
The query string
values
A list of values to be written to "?" placeholders in the query
types
A list of hibernate types of the values

Returns

An enumerator

Remarks

If the query has multiple return values, values will be returned in an array of type object[].

Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So Enumerator() is usually a less efficient way to retrieve object than Find().

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Evict Method

Remove this instance from the session cache.

public void Evict (object obj)

Parameters

obj
a persistent instance

Remarks

Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped with cascade="all" or cascade="all-delete-orphan".

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Filter Method

Apply a filter to a persistent collection.

[System.Obsolete("Use ISession.CreateFilter().List()")]
public ICollection Filter (object collection, string filter)

Parameters

collection
A persistent collection to filter
filter
A filter query string

Returns

The resulting collection

Remarks

A filter is a Hibernate query that may refer to this, the collection element. Filters allow efficient access to very large lazy collections. (Executing the filter does not initialize the collection.)

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Filter Method

Apply a filter to a persistent collection, binding the given parameter to a "?" placeholder

[System.Obsolete("Use ISession.CreateFilter().SetXYZ().List()")]
public ICollection Filter (object collection, string filter, object value, NHibernate.Type.IType type)

Parameters

collection
A persistent collection to filter
filter
A filter query string
value
A value to be written to a "?" placeholder in the query
type
The hibernate type of value

Returns

A collection

Remarks

A filter is a Hibernate query that may refer to this, the collection element. Filters allow efficient access to very large lazy collections. (Executing the filter does not initialize the collection.)

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Filter Method

Apply a filter to a persistent collection, binding the given parameters to "?" placeholders.

[System.Obsolete("Use ISession.CreateFilter().SetXYZ().List()")]
public ICollection Filter (object collection, string filter, object[] values, NHibernate.Type.IType[] types)

Parameters

collection
A persistent collection to filter
filter
A filter query string
values
The values to be written to "?" placeholders in the query
types
The hibernate types of the values

Returns

A collection

Remarks

A filter is a Hibernate query that may refer to this, the collection element. Filters allow efficient access to very large lazy collections. (Executing the filter does not initialize the collection.)

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Find Method

Execute a query

[System.Obsolete("Use ISession.CreateQuery().List()")]
public IList Find (string query)

Parameters

query
A query expressed in Hibernate's query language

Returns

A distinct list of instances

Remarks

See IQuery.List for implications of cache usage.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Find Method

Execute a query, binding a value to a "?" parameter in the query string.

[System.Obsolete("Use ISession.CreateQuery().SetXYZ().List()")]
public IList Find (string query, object value, NHibernate.Type.IType type)

Parameters

query
The query string
value
A value to be bound to a "?" placeholder
type
The Hibernate type of the value

Returns

A distinct list of instances

Remarks

See IQuery.List for implications of cache usage.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Find Method

Execute a query, binding an array of values to a "?" parameters in the query string.

[System.Obsolete("Use ISession.CreateQuery().SetXYZ().List()")]
public IList Find (string query, object[] values, NHibernate.Type.IType[] types)

Parameters

query
The query string
values
An array of values to be bound to the "?" placeholders
types
An array of Hibernate types of the values

Returns

A distinct list of instances

Remarks

See IQuery.List for implications of cache usage.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Flush Method

Force the ISession to flush.

public void Flush ()

Remarks

Must be called at the end of a unit of work, before commiting the transaction and closing the session (Transaction.Commit() calls this method). Flushing if the process of synchronising the underlying persistent store with persistable state held in memory.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

FlushMode Property

Determines at which points Hibernate automatically flushes the session.

public FlushMode FlushMode { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

For a readonly session, it is reasonable to set the flush mode to FlushMode.Never at the start of the session (in order to achieve some extra performance).

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Get Method

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance, or a proxy for the instance, is already associated with the session, return that instance or proxy.)

public object Get (Type clazz, object id)

Parameters

clazz
a persistent class
id
an identifier

Returns

a persistent instance or null

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Get Method

Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. Obtain the specified lock mode if the instance exists.

public object Get (Type clazz, object id, LockMode lockMode)

Parameters

clazz
a persistent class
id
an identifier
lockMode
the lock mode

Returns

a persistent instance or null

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Get<T> Generic Method

Strongly-typed version of ISession.Get(Type, object)

public T Get<T> (object id)

Type Parameters

T
Documentation for this section has not yet been entered.

Parameters

id
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Get<T> Generic Method

Strongly-typed version of ISession.Get(Type, object, LockMode)

public T Get<T> (object id, LockMode lockMode)

Type Parameters

T
Documentation for this section has not yet been entered.

Parameters

id
Documentation for this section has not yet been entered.
lockMode
Documentation for this section has not yet been entered.

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

GetCurrentLockMode Method

Determine the current lock mode of the given object

public LockMode GetCurrentLockMode (object obj)

Parameters

obj
A persistent instance

Returns

The current lock mode

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

GetEnabledFilter Method

Retrieve a currently enabled filter by name.

public IFilter GetEnabledFilter (string filterName)

Parameters

filterName
The name of the filter to be retrieved.

Returns

The Filter instance representing the enabled fiter.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

GetIdentifier Method

Return the identifier of an entity instance cached by the ISession

public object GetIdentifier (object obj)

Parameters

obj
a persistent instance

Returns

the identifier

Remarks

Throws an exception if the instance is transient or associated with a different ISession

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

GetNamedQuery Method

Obtain an instance of NHibernate.IQuery for a named query string defined in the mapping file.

public IQuery GetNamedQuery (string queryName)

Parameters

queryName
The name of a query defined externally.

Returns

An NHibernate.IQuery from a named query string.

Remarks

The query can be either in HQL or SQL format.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

GetSessionImplementation Method

Gets the session implementation.

public NHibernate.Engine.ISessionImplementor GetSessionImplementation ()

Returns

An NHibernate implementation of the interface

Remarks

This method is provided in order to get the NHibernate implementation of the session from wrapper implementions. Implementors of the interface should return the NHibernate implementation of this method.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

IsConnected Property

Is the ISession currently connected?

public bool IsConnected { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

IsDirty Method

Does this ISession contain any changes which must be synchronized with the database? Would any SQL be executed if we flushed this session?

public bool IsDirty ()

Returns

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

IsOpen Property

Is the ISession still open?

public bool IsOpen { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Load Method

Read the persistent state associated with the given identifier into the given transient instance.

public void Load (object obj, object id)

Parameters

obj
An "empty" instance of the persistent class
id
A valid identifier of an existing persistent instance of the class

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Load Method

Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.

public object Load (Type theType, object id)

Parameters

theType
A persistent class
id
A valid identifier of an existing persistent instance of the class

Returns

The persistent instance or proxy

Remarks

You should not use this method to determine if an instance exists (use a query or ISession.Get(Type, object) instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Load Method

Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode.

public object Load (Type theType, object id, LockMode lockMode)

Parameters

theType
A persistent class
id
A valid identifier of an existing persistent instance of the class
lockMode
The lock level

Returns

the persistent instance

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Load<T> Generic Method

Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.

public T Load<T> (object id)

Type Parameters

T
A persistent class

Parameters

id
A valid identifier of an existing persistent instance of the class

Returns

The persistent instance or proxy

Remarks

You should not use this method to determine if an instance exists (use a query or ISession.Get``1(object) instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Load<T> Generic Method

Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode.

public T Load<T> (object id, LockMode lockMode)

Type Parameters

T
A persistent class

Parameters

id
A valid identifier of an existing persistent instance of the class
lockMode
The lock level

Returns

the persistent instance

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Lock Method

Obtain the specified lock level upon the given object.

public void Lock (object obj, LockMode lockMode)

Parameters

obj
A persistent instance
lockMode
The lock level

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Reconnect Method

Obtain a new ADO.NET connection.

public void Reconnect ()

Remarks

This is used by applications which require long transactions

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Reconnect Method

Reconnect to the given ADO.NET connection.

public void Reconnect (System.Data.IDbConnection connection)

Parameters

connection
An ADO.NET connection

Remarks

This is used by applications which require long transactions

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Refresh Method

Re-read the state of the given instance from the underlying database.

public void Refresh (object obj)

Parameters

obj
A persistent instance

Remarks

It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.

For example, [The '' type of list has not been implemented in the ECMA stylesheet.]

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Refresh Method

Re-read the state of the given instance from the underlying database, with the given LockMode.

public void Refresh (object obj, LockMode lockMode)

Parameters

obj
a persistent or transient instance
lockMode
the lock mode to use

Remarks

It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Replicate Method

Persist all reachable transient objects, reusing the current identifier values. Note that this will not trigger the Interceptor of the Session.

public void Replicate (object obj, ReplicationMode replicationMode)

Parameters

obj
replicationMode

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Save Method

Persist the given transient instance, first assigning a generated identifier.

public object Save (object obj)

Parameters

obj
A transient instance of a persistent class

Returns

The generated identifier

Remarks

Save will use the current value of the identifier property if the Assigned generator is used.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Save Method

Persist the given transient instance, using the given identifier.

public void Save (object obj, object id)

Parameters

obj
A transient instance of a persistent class
id
An unused valid identifier

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

SaveOrUpdate Method

Either Save() or Update() the given instance, depending upon the value of its identifier property.

public void SaveOrUpdate (object obj)

Parameters

obj
A transient instance containing new or updated state

Remarks

By default the instance is always saved. This behaviour may be adjusted by specifying an unsaved-value attribute of the identifier property mapping

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

SaveOrUpdateCopy Method

Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

public object SaveOrUpdateCopy (object obj)

Parameters

obj
a transient instance with state to be copied

Returns

an updated persistent instance

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

SaveOrUpdateCopy Method

Copy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.

public object SaveOrUpdateCopy (object obj, object id)

Parameters

obj
a persistent or transient instance with state to be copied
id
the identifier of the instance to copy to

Returns

an updated persistent instance

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

SessionFactory Property

Get the NHibernate.ISessionFactory that created this instance.

public ISessionFactory SessionFactory { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Transaction Property

Get the current Unit of Work and return the associated ITransaction object.

public ITransaction Transaction { get; }

Value

Documentation for this section has not yet been entered.

Remarks

Documentation for this section has not yet been entered.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Update Method

Update the persistent instance with the identifier of the given transient instance.

public void Update (object obj)

Parameters

obj
A transient instance containing updated state

Remarks

If there is a persistent instance with the same identifier, an exception is thrown. If the given transient instance has a null identifier, an exception will be thrown.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000

Update Method

Update the persistent state associated with the given identifier.

public void Update (object obj, object id)

Parameters

obj
A transient instance containing updated state
id
Identifier of persistent instance

Remarks

An exception is thrown if there is a persistent instance with the same identifier in the current session.

Requirements

Namespace: NHibernate
Assembly: NHibernate (in NHibernate.dll)
Assembly Versions: 1.2.1.4000