de.espirit.or
Interface Session


public interface Session

Since:
4.0.17

Method Summary
 void addSessionListener(de.espirit.or.SessionListener listener)
          Add the listener to this session.
 void close()
          Close the session and release all used resources.
 void commit()
          Make all changes since the last commit or rollback persistent.
 void commit(String comment)
          Make all changes since the last commit or rollback persistent with the given comment as revision comment.
 Entity createEntity(String type)
          Create a new entity of the given type
 Select createSelect(String name)
          Create a select for the entity type name with the actual session time as query time.
 void delete(Entity entity)
          Mark the entity as deleted.
 de.espirit.or.EntityList executeQuery(Select select)
           
 de.espirit.or.DumpData exportData(String name, long from, long to)
           
 de.espirit.or.schema.Schema extractSchemaFromDB(String schemaName)
          Update the assigned schema with the structure of DB schema schemaName.
 List<KeyValue> fetchKeys(Select select)
          Return a list of key values of all entities which fullfill the criterion defined by select.
 Entity find(de.espirit.or.schema.Identifier identifier)
          Return the entity with the given identifier.
 Entity find(KeyValue keyValue)
          Return the entity with the given keyValue.
 Entity find(String entityTypeName, Object... key)
          Return the entity of type entityTypeName with the id key.
 Entity findNotNull(KeyValue keyValue)
          Returns an entity with the given keyValue even if it doesn't exist.
 Entity findNotNull(String entityTypeName, Object... key)
          Returns an entity of type entityTypeName with the id key even if it doesn't exists.
 Set<Entity> getChanged()
          Return the set of modified but not committed entities in this session.
 List<Entity> getDeletedEntities(String entityTypeName)
          Get all deleted entities from type entityTypeName.
 List<Entity> getHistory(KeyValue keyValue)
          Return the history of the entity with the given keyValue.
 List<Entity> getInvalidEntities(KeyValue keyValue)
          Return a list of invalid entities of the given keyValue..
 long getLastChangeTime(Select select)
          Get the timestamp of the last change of the result set of the specified select.
 long getLastChangeTime(Select select, long after)
          Get the timestamp of the last change of the result set of the specified select after the specified timestamp.
 Set<KeyValue> getReleasedDeleted(String entityTypeName)
          Get the key values of all entities of the given entity type which are deleted but still released.
 de.espirit.or.schema.Schema getSchema()
          Return the schema assigned with this session.
 boolean hasChangedAfter(Select select, long time)
          Return true if the result of the query with the given select is not empty.
 boolean hasChanges()
          Returns true if there are uncommitted changes, see commit and rollback.
 void importData(de.espirit.or.DumpData data)
          Import the data into the database connected by this session.
 void importUpdateData(de.espirit.or.DumpData data)
          Import or update the data into the database connected by this session.
 boolean isReadOnly()
          If the session is "read only" no modifications are permitted.
 boolean isRelease()
          Return true if this session is a release session else false.
 void release(Entity entity)
          Release the given entity.
 void removeSessionListener(de.espirit.or.SessionListener listener)
          Remove the listener from this session.
 void restore(de.espirit.or.schema.Identifier identifier)
          Restore the deleted entity with the identifier.
 void rollback()
          Undo all changes since the last commit or rollback.
 de.espirit.or.schema.Schema syncSchemaWithDB(de.espirit.or.schema.Schema schema, boolean importMode)
          Update the DB structure with the given schema.
 void updateWorkflowData(Entity entity, Color wfColor, long taskId)
          Set the workflow color and the task id of entity to wfColor and taskId.
 Select xml2Select(String queryXml)
          Construct a select from the xml document queryXml.
 

Method Detail

getSchema

@NotNull
de.espirit.or.schema.Schema getSchema()
Return the schema assigned with this session.

Since:
4.0.17

createEntity

@NotNull
Entity createEntity(@NotNull
                            String type)
                    throws de.espirit.or.ORException
Create a new entity of the given type

Throws:
de.espirit.or.ORException
Since:
4.0.17

find

@Nullable
Entity find(@NotNull
                     KeyValue keyValue)
Return the entity with the given keyValue.

Since:
4.0.17

findNotNull

@NotNull
Entity findNotNull(@NotNull
                           KeyValue keyValue)
Returns an entity with the given keyValue even if it doesn't exist. In that case the entity's state is NOT_EXISTS.

Since:
4.1.2

find

@Nullable
Entity find(@NotNull
                     String entityTypeName,
                     @NotNull
                     Object... key)
Return the entity of type entityTypeName with the id key.

Since:
4.0.17

findNotNull

@NotNull
Entity findNotNull(@NotNull
                           String entityTypeName,
                           @NotNull
                           Object... key)
Returns an entity of type entityTypeName with the id key even if it doesn't exists. In that case the entity's state is NOT_EXISTS.

Since:
4.1.2

find

@NotNull
Entity find(@NotNull
                    de.espirit.or.schema.Identifier identifier)
Return the entity with the given identifier.

Important: Keep in mind the difference between an Identifier and KeyValue, use Session.find(KeyValue) if possible!

Since:
4.0.17

createSelect

@NotNull
Select createSelect(@NotNull
                            String name)
                    throws de.espirit.or.SchemaException
Create a select for the entity type name with the actual session time as query time.

Throws:
de.espirit.or.SchemaException
Since:
4.0.17

xml2Select

@NotNull
Select xml2Select(@NotNull
                          String queryXml)
                  throws de.espirit.or.ORException
Construct a select from the xml document queryXml.

Throws:
de.espirit.or.ORException
Since:
4.0.17

delete

void delete(@NotNull
            Entity entity)
            throws de.espirit.or.ORException
Mark the entity as deleted. The change is persistent by the next Session.commit().

Throws:
de.espirit.or.ORException
Since:
4.0.17

executeQuery

@NotNull
de.espirit.or.EntityList executeQuery(@NotNull
                                              Select select)
                                      throws de.espirit.or.ORException
Throws:
de.espirit.or.ORException
Since:
4.0.17

getDeletedEntities

@NotNull
List<Entity> getDeletedEntities(@NotNull
                                        String entityTypeName)
                                throws de.espirit.or.ORException
Get all deleted entities from type entityTypeName.

Throws:
de.espirit.or.ORException
Since:
4.0.19

getReleasedDeleted

@NotNull
Set<KeyValue> getReleasedDeleted(@NotNull
                                         String entityTypeName)
                                 throws de.espirit.or.ORException
Get the key values of all entities of the given entity type which are deleted but still released.

Throws:
de.espirit.or.ORException
Since:
4.0.91

getInvalidEntities

@NotNull
List<Entity> getInvalidEntities(@NotNull
                                        KeyValue keyValue)
                                throws de.espirit.or.ORException
Return a list of invalid entities of the given keyValue.. For non-temporal schemas this method delivers an empty list.

Throws:
de.espirit.or.ORException
Since:
4.0.22
See Also:
Session.getHistory(de.espirit.or.schema.KeyValue)

getHistory

@NotNull
List<Entity> getHistory(@NotNull
                                KeyValue keyValue)
                        throws de.espirit.or.ORException
Return the history of the entity with the given keyValue. For non-temporal schemas this method delivers an empty list. In contrast to Session.getInvalidEntities(de.espirit.or.schema.KeyValue) the returned list includes the also the most actual value of the entity.

Parameters:
keyValue - the key of the entity
Returns:
the history of changes for the specified entity
Throws:
ORException - in case of database problems
Since:
4.2.44
See Also:
Session.getInvalidEntities(de.espirit.or.schema.KeyValue)

restore

void restore(@NotNull
             de.espirit.or.schema.Identifier identifier)
             throws de.espirit.or.ORException
Restore the deleted entity with the identifier.

Throws:
de.espirit.or.ORException
Since:
4.0.20

fetchKeys

@NotNull
List<KeyValue> fetchKeys(@NotNull
                                 Select select)
                         throws de.espirit.or.ORException
Return a list of key values of all entities which fullfill the criterion defined by select.

Throws:
de.espirit.or.ORException
Since:
4.0.17

importData

void importData(@NotNull
                de.espirit.or.DumpData data)
                throws de.espirit.or.ORException
Import the data into the database connected by this session.

Throws:
de.espirit.or.ORException
Since:
4.0.17

importUpdateData

void importUpdateData(@NotNull
                      de.espirit.or.DumpData data)
                      throws de.espirit.or.ORException
Import or update the data into the database connected by this session.

Throws:
de.espirit.or.ORException
Since:
4.1.16

exportData

@NotNull
de.espirit.or.DumpData exportData(@NotNull
                                          String name,
                                          long from,
                                          long to)
                                  throws de.espirit.or.ORException
Throws:
de.espirit.or.ORException
Since:
4.0.17

rollback

void rollback()
Undo all changes since the last commit or rollback.

Since:
4.0.17

commit

void commit()
            throws de.espirit.or.ORException
Make all changes since the last commit or rollback persistent.

Throws:
de.espirit.or.ORException
Since:
4.0.17

commit

void commit(String comment)
            throws de.espirit.or.ORException
Make all changes since the last commit or rollback persistent with the given comment as revision comment.

Throws:
de.espirit.or.ORException
Since:
4.0.27

close

void close()
           throws de.espirit.or.ORException
Close the session and release all used resources. If a transaction is open then this will will be committed.

Throws:
de.espirit.or.ORException
Since:
4.0.17

release

void release(@NotNull
             Entity entity)
             throws de.espirit.or.ORException
Release the given entity.

Throws:
de.espirit.or.ORException
Since:
4.0.17

isRelease

boolean isRelease()
Return true if this session is a release session else false. All entities manages by a release session must be in the release state. A release session supports only the following operations All other operations like create a new entity Session.createEntity(String), import data Session.importData(DumpData), create a new schema form the database Session.extractSchemaFromDB(String) and update the database structure Session.syncSchemaWithDB(Schema, boolean) are not supported. An UnsupportedOperationException will be thrown if these methods is called in a release session.

Since:
4.0.17

extractSchemaFromDB

de.espirit.or.schema.Schema extractSchemaFromDB(String schemaName)
Update the assigned schema with the structure of DB schema schemaName.

Since:
4.0.17

syncSchemaWithDB

de.espirit.or.schema.Schema syncSchemaWithDB(@NotNull
                                             de.espirit.or.schema.Schema schema,
                                             boolean importMode)
Update the DB structure with the given schema. If importMode is true then no foreign key and primary key is created in the DB in other case all primary and foreign keys will be created

Since:
4.0.17

isReadOnly

boolean isReadOnly()
If the session is "read only" no modifications are permitted.

Since:
4.0.17

hasChanges

boolean hasChanges()
Returns true if there are uncommitted changes, see commit and rollback.

Since:
4.0.17
See Also:
commit, rollback

getChanged

Set<Entity> getChanged()
Return the set of modified but not committed entities in this session.

Since:
4.0.17

hasChangedAfter

boolean hasChangedAfter(@NotNull
                        Select select,
                        long time)
                        throws de.espirit.or.ORException
Return true if the result of the query with the given select is not empty.

Throws:
de.espirit.or.ORException
Since:
4.0.17

getLastChangeTime

long getLastChangeTime(@NotNull
                       Select select)
                       throws de.espirit.or.ORException
Get the timestamp of the last change of the result set of the specified select. Only changes of the result table are considered.

Only supported for temporal schema.

Throws:
de.espirit.or.ORException
Since:
4.0.19
See Also:
Session.getLastChangeTime(de.espirit.or.query.Select, long)

getLastChangeTime

long getLastChangeTime(@NotNull
                       Select select,
                       long after)
                       throws de.espirit.or.ORException
Get the timestamp of the last change of the result set of the specified select after the specified timestamp. Only changes of the result table are considered.

Only supported for temporal schema.

Throws:
de.espirit.or.ORException
Since:
4.2.400
See Also:
Session.getLastChangeTime(de.espirit.or.query.Select)

addSessionListener

void addSessionListener(@NotNull
                        de.espirit.or.SessionListener listener)
Add the listener to this session.

Since:
4.0.17

removeSessionListener

void removeSessionListener(@NotNull
                           de.espirit.or.SessionListener listener)
Remove the listener from this session.

Since:
4.0.17

updateWorkflowData

void updateWorkflowData(@NotNull
                        Entity entity,
                        Color wfColor,
                        long taskId)
                        throws de.espirit.or.ORException
Set the workflow color and the task id of entity to wfColor and taskId. This update doesn't create a new version of entity in the database and is executed immediately.

Throws:
de.espirit.or.ORException
Since:
4.0.17


Copyright © 2012 e-Spirit AG. All Rights Reserved. Build 4.2.480