public class KCSessionManager
extends it.unimi.dico.islab.idbs2.common.AbstractSessionManager
Modifier and Type | Field and Description |
---|---|
protected static boolean |
AUTO_DATABASE_COHERENCE |
static DocumentManager |
dm
DocumentManager reference, used to manage Document objects. |
static KCManager |
kcm
KCManager reference, used to manage KnowledgeChunk objects. |
static PredicateManager |
pm
PredicateManager reference, used to manage Predicate objects. |
static TermManager |
tm
TermManager reference, used to manage Term objects. |
static TypeManager |
tym
TypeManager reference, used to manage Type objects. |
Modifier and Type | Method and Description |
---|---|
static void |
beginTransaction()
Start a new transaction for the internal Session.
|
protected static void |
checkActiveTransaction()
Check if the internal session has an active transaction, otherwise creates automatically a new transaction
warning the user.
|
static void |
commitTransaction()
Commit the internal session active transaction.
|
static boolean |
createDb()
TODO: Scrivere guida!!
|
static Query |
executeQuery(String query)
Executes the HQL (Hibernate Query Language)
query given as input using the
internal session (requires an explicit call to beginTransaction() ). |
static Boolean |
getAutoDatabaseCoherence() |
protected static Session |
getInternalSession()
Getter for the internal Hibernate Session.
|
static SessionFactory |
getSessionFactory()
Returns an Hibernate Session Factory created for this cloud model.
|
static SessionFactory |
getSessionFactory(File confFile)
Same as
getSessionFactory() . |
static void |
rollbackTransaction() |
protected static void |
saveOrUpdate(Object obj)
Give persistence (on relational database) to an object mapped with Hibernate using the
internal
Session Factory of this class. |
void |
setAutoDatabaseCoherence(boolean active)
Activate/deactivate the database coherence system; this system could be useful when adding new
KCs to and existing and already filled database.
|
public static KCManager kcm
KCManager
reference, used to manage KnowledgeChunk
objects.public static DocumentManager dm
DocumentManager
reference, used to manage Document
objects.public static TypeManager tym
TypeManager
reference, used to manage Type
objects.public static TermManager tm
TermManager
reference, used to manage Term
objects.public static PredicateManager pm
PredicateManager
reference, used to manage Predicate
objects.protected static boolean AUTO_DATABASE_COHERENCE
public static Query executeQuery(String query)
query
given as input using the
internal session (requires an explicit call to beginTransaction()
).query
- the HQL query to be executed. Only SELECT
queries are accepted.Object
s as result of the query or null
if no result has
been returned.protected static void saveOrUpdate(Object obj)
Give persistence (on relational database) to an object mapped with Hibernate using the
internal Session Factory
of this class.
obj
- The Hibernate mapped object to be persisted.protected static void checkActiveTransaction()
protected static Session getInternalSession()
Session
managed by this class.public static void beginTransaction()
public static void commitTransaction()
public static void rollbackTransaction()
public static SessionFactory getSessionFactory()
Returns an Hibernate Session Factory created for this cloud model. This Session Factory will be different
at any call of this method and is different from the internal Session Factory used by other methods
(e.g. saveOrUpdate and getKnowledgeChunkById
).
This session factory is created using the config/kcDatabaseConfiguration.xml
file.
SessionFactory
public static SessionFactory getSessionFactory(File confFile)
getSessionFactory()
. Only difference is that the configuration file
the SessionFactory will be built upon is passed as argument. This method can be used to obtain new
SessionFactories for databases different from the standard one.confFile
- the configuration file in a standard xml Hibernate version.public static boolean createDb()
SQLException
public void setAutoDatabaseCoherence(boolean active)
Activate/deactivate the database coherence system; this system could be useful when adding new
KCs to and existing and already filled database. When activated the behavior of the
addType
, addTerm
, and addDocument
methods are changed.
For better understanding we present the following example based on the addType
method:
public static Boolean getAutoDatabaseCoherence()
for better explanation.