Skip to content
Vadim Lopatin edited this page Jun 20, 2013 · 1 revision

Session

Use Session to load or save entities, execute HQL Query.

Key methods of Session interface:

Method Description
T get(T : Object, ID)(ID id) Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.
T load(T : Object, ID)(ID id) Read the persistent state associated with the given identifier into the given transient instance.
void load(T : Object, ID)(T obj, ID id) Read the persistent state associated with the given identifier into the given transient instance.
Object getObject(string entityName, Variant id) Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.
Object loadObject(string entityName, Variant id) Read the persistent state associated with the given identifier into the given transient instance.
void loadObject(Object obj, Variant id) Read the persistent state associated with the given identifier into the given transient instance
void refresh(Object obj) Re-read the state of the given instance from the underlying database
Variant save(Object obj) Persist the given transient instance, first assigning a generated identifier
void persist(Object obj) Persist the given transient instance.
void update(Object object) Update the persistent instance with the identifier of the given detached instance.
void remove(Object object) remove object from DB (renamed from original Session.delete - it's keyword in D)
Query createQuery(string queryString) Create a new instance of Query for the given HQL query string
EntityMetaData getMetaData() get metadata
Connection close() closes session
bool isOpen() Check if the session is still open
bool isConnected() Check if the session is currently connected.
string getEntityName(Object object) Lookup metadata to find entity name for object.
string getEntityName(TypeInfo_Class type) Lookup metadata to find entity name for class type info.
SessionFactory getSessionFactory() Retrieve session factory used to create this session

Not yet supported methods:

Method Description
EntityMetaData getMetaData() get metadata
Transaction beginTransaction() not supported in current implementation
void cancelQuery() not supported in current implementation
void clear() not supported in current implementation
Connection close() closes session
bool isDirty() Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?
bool contains(Object object) Check if this instance is associated with this Session.
Clone this wiki locally