public class XWikiHibernateBaseStore
extends com.xpn.xwiki.internal.store.AbstractXWikiStore
Modifier and Type | Class and Description |
---|---|
static interface |
XWikiHibernateBaseStore.HibernateCallback<T>
Callback (closure) interface for operations in hibernate.
|
Modifier and Type | Field and Description |
---|---|
protected com.xpn.xwiki.internal.store.hibernate.HibernateConfiguration |
hibernateConfiguration |
static String |
HINT
The role hint of this component.
|
protected org.xwiki.logging.LoggerManager |
loggerManager
LoggerManager to suspend logging during normal faulty SQL operation.
|
protected com.xpn.xwiki.internal.store.hibernate.HibernateStore |
store |
Constructor and Description |
---|
XWikiHibernateBaseStore()
Empty constructor needed for component manager.
|
XWikiHibernateBaseStore(String hibpath)
Deprecated.
1.6M1. Use ComponentManager.lookup(String) instead.
|
XWikiHibernateBaseStore(XWiki xwiki,
XWikiContext context)
Deprecated.
1.6M1. Use ComponentManager.lookup(String) instead.
|
Modifier and Type | Method and Description |
---|---|
boolean |
beginTransaction(boolean withTransaction,
XWikiContext context)
Deprecated.
since 4.0M1, use
beginTransaction(SessionFactory, XWikiContext) |
boolean |
beginTransaction(org.hibernate.SessionFactory sfactory,
boolean withTransaction,
XWikiContext context)
Deprecated.
since 4.0M1, use
beginTransaction(SessionFactory, XWikiContext) |
boolean |
beginTransaction(org.hibernate.SessionFactory sfactory,
XWikiContext inputxcontext)
Begins a transaction with a specific SessionFactory.
|
boolean |
beginTransaction(XWikiContext context)
Begins a transaction if the context does not contains any.
|
void |
checkHibernate(XWikiContext context)
Initializes Hibernate.
|
void |
cleanUp(XWikiContext inputxcontext)
Cleanup all sessions Used at the shutdown time
|
protected void |
createHibernateSequenceIfRequired(String[] schemaSQL,
String schemaName,
org.hibernate.Session session)
Deprecated.
since 11.5RC1
|
String |
dynamicMappingTableName(String className)
Return the name generated for a dynamic mapped object.
|
void |
endTransaction(XWikiContext inputxcontext,
boolean commit)
Ends a transaction and close the session.
|
void |
endTransaction(XWikiContext context,
boolean commit,
boolean withTransaction)
Deprecated.
since 4.0M1, use
endTransaction(XWikiContext, boolean) |
protected String |
escapeSchema(String schema,
XWikiContext context)
Escape schema name depending of the database engine.
|
<T> T |
execute(XWikiContext context,
boolean bTransaction,
boolean doCommit,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Deprecated.
|
<T> T |
execute(XWikiContext inputxcontext,
boolean doCommit,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute method for operations in hibernate.
|
<T> T |
executeRead(XWikiContext context,
boolean bTransaction,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Deprecated.
|
<T> T |
executeRead(XWikiContext context,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute method for read-only operations in hibernate.
|
<T> T |
executeWrite(XWikiContext context,
boolean bTransaction,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Deprecated.
|
<T> T |
executeWrite(XWikiContext context,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute method for read-write operations in hibernate.
|
<T> T |
failSafeExecute(XWikiContext inputxcontext,
boolean doCommit,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute method for operations in hibernate in an independent session (but not closing the current one if any).
|
<T> T |
failSafeExecuteRead(XWikiContext context,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute hibernate read-only operation in a independent session (but not closing the current one if any).
|
<T> T |
failSafeExecuteWrite(XWikiContext context,
XWikiHibernateBaseStore.HibernateCallback<T> cb)
Execute hibernate read-only operation in a independent session (but not closing the current one if any).
|
org.hibernate.cfg.Configuration |
getConfiguration() |
Map<String,String> |
getConnections()
Deprecated.
since 9.9RC1
|
DatabaseMetaData |
getDatabaseMetaData()
Retrieve metadata about the database used (name, version, etc).
|
DatabaseProduct |
getDatabaseProductName()
Retrieve the current database product name.
|
DatabaseProduct |
getDatabaseProductName(XWikiContext context)
Deprecated.
since 4.0M1 use
getDatabaseProductName() |
org.hibernate.dialect.Dialect |
getDialect() |
protected org.xwiki.context.Execution |
getExecution()
We had to add this method because the Component Manager doesn't inject a field in the base class if a derived
class defines a field with the same name.
|
String |
getHint() |
protected org.hibernate.cfg.Configuration |
getMapping(String className,
String customMapping)
Deprecated.
since 11.5RC1
|
org.hibernate.boot.Metadata |
getMetadata() |
int |
getNbConnections()
Deprecated.
since 9.9RC1
|
String |
getPath()
Allows to get the current hibernate config file path
|
protected String |
getSchemaFromWikiName(String wikiName,
DatabaseProduct databaseProduct,
XWikiContext inputxcontext)
Convert wiki name in database/schema name.
|
protected String |
getSchemaFromWikiName(String wikiId,
XWikiContext inputxcontext)
Convert wiki name in database/schema name.
|
String |
getSchemaFromWikiName(XWikiContext context)
Convert context's database in real database/schema name.
|
String[] |
getSchemaUpdateScript(org.hibernate.cfg.Configuration config,
XWikiContext inputxcontext)
Deprecated.
do nothing since 11.5RC1
|
org.hibernate.Session |
getSession(XWikiContext inputxcontext)
This get's the current session.
|
org.hibernate.SessionFactory |
getSessionFactory() |
org.hibernate.Transaction |
getTransaction(XWikiContext inputxcontext)
Allows to get the current transaction from the context This is set in beginTransaction
|
protected boolean |
isInSchemaMode() |
protected boolean |
isVirtual(XWikiContext context)
Deprecated.
Virtual mode is on by default, starting with XWiki 5.0M2.
|
protected String |
makeMapping(String className,
String customMapping)
Build a new XML string to define the provided mapping.
|
void |
setDatabase(org.hibernate.Session session,
XWikiContext inputxcontext)
Virtual Wikis Allows to switch database connection
|
void |
setNbConnections(int nbConnections)
Deprecated.
since 9.9RC1
|
void |
setPath(String hibpath)
Allows to set the current hibernate config file path
|
void |
setSession(org.hibernate.Session session,
XWikiContext inputxcontext)
Allows to set the current session in the context This is set in beginTransaction
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Deprecated.
does not do anything since 11.5RC1
|
void |
setTransaction(org.hibernate.Transaction transaction,
XWikiContext inputxcontext)
Allows to set the current transaction This is set in beginTransaction
|
void |
shutdownHibernate(XWikiContext inputxcontext)
Deprecated.
automatically done when the
HibernateSessionFactory component is disposed |
void |
updateSchema(BaseClass bclass,
XWikiContext inputxcontext)
Custom Mapping This function update the schema based on the dynamic custom mapping provided by the class
|
void |
updateSchema(String[] createSQL,
XWikiContext inputxcontext)
Deprecated.
since 11.5RC1
|
void |
updateSchema(XWikiContext inputxcontext)
Allows to update the schema to match the hibernate mapping
|
void |
updateSchema(XWikiContext inputxcontext,
boolean force)
Allows to update the schema to match the hibernate mapping
|
public static final String HINT
@Inject protected org.xwiki.logging.LoggerManager loggerManager
@Inject protected com.xpn.xwiki.internal.store.hibernate.HibernateStore store
@Inject protected com.xpn.xwiki.internal.store.hibernate.HibernateConfiguration hibernateConfiguration
@Deprecated public XWikiHibernateBaseStore(XWiki xwiki, XWikiContext context)
xwiki
- context
- @Deprecated public XWikiHibernateBaseStore(String hibpath)
hibpath
- public XWikiHibernateBaseStore()
public String getHint()
public String getPath()
public void setPath(String hibpath)
hibpath
- public DatabaseMetaData getDatabaseMetaData()
Note that the database metadata is not cached and it's retrieved at each call. If all you need is the database
product name you should use getDatabaseProductName()
instead, which is cached.
public DatabaseProduct getDatabaseProductName()
Note that the database product name is cached for improved performances.
DatabaseProduct
@Deprecated public DatabaseProduct getDatabaseProductName(XWikiContext context)
getDatabaseProductName()
public org.hibernate.Session getSession(XWikiContext inputxcontext)
inputxcontext
- public void setSession(org.hibernate.Session session, XWikiContext inputxcontext)
session
- inputxcontext
- public org.hibernate.Transaction getTransaction(XWikiContext inputxcontext)
inputxcontext
- public void setTransaction(org.hibernate.Transaction transaction, XWikiContext inputxcontext)
transaction
- inputxcontext
- @Deprecated public void shutdownHibernate(XWikiContext inputxcontext) throws org.hibernate.HibernateException
HibernateSessionFactory
component is disposedinputxcontext
- org.hibernate.HibernateException
public void updateSchema(XWikiContext inputxcontext) throws org.hibernate.HibernateException
inputxcontext
- org.hibernate.HibernateException
public void updateSchema(XWikiContext inputxcontext, boolean force) throws org.hibernate.HibernateException
inputxcontext
- force
- defines wether or not to force the update despite the xwiki.cfg settingsorg.hibernate.HibernateException
protected String getSchemaFromWikiName(String wikiName, DatabaseProduct databaseProduct, XWikiContext inputxcontext)
wikiName
- the wiki name to convert.databaseProduct
- the database engine type.inputxcontext
- the XWiki context.protected String getSchemaFromWikiName(String wikiId, XWikiContext inputxcontext)
Need hibernate to be initialized.
wikiId
- the wiki name to convert.inputxcontext
- the XWiki context.public String getSchemaFromWikiName(XWikiContext context)
Need hibernate to be initialized.
context
- the XWiki context.@Deprecated public String[] getSchemaUpdateScript(org.hibernate.cfg.Configuration config, XWikiContext inputxcontext) throws org.hibernate.HibernateException
config
- inputxcontext
- org.hibernate.HibernateException
@Deprecated protected void createHibernateSequenceIfRequired(String[] schemaSQL, String schemaName, org.hibernate.Session session)
schemaSQL
- the list of SQL commands to execute to update the schema, possibly containing the
"hibernate_sequence" sequence creationschemaName
- the schema name corresponding to the subwiki being updatedsession
- the Hibernate session, used to get the Dialect object@Deprecated public void updateSchema(String[] createSQL, XWikiContext inputxcontext) throws org.hibernate.HibernateException
createSQL
- inputxcontext
- org.hibernate.HibernateException
public void updateSchema(BaseClass bclass, XWikiContext inputxcontext) throws XWikiException, org.hibernate.HibernateException
bclass
- inputxcontext
- XWikiException
org.hibernate.HibernateException
public void checkHibernate(XWikiContext context) throws org.hibernate.HibernateException
context
- org.hibernate.HibernateException
@Deprecated protected boolean isVirtual(XWikiContext context)
context
- the XWiki context.public void setDatabase(org.hibernate.Session session, XWikiContext inputxcontext) throws XWikiException
session
- inputxcontext
- XWikiException
protected String escapeSchema(String schema, XWikiContext context)
schema
- the schema name to escapecontext
- the XWiki context to get database engine identifierpublic boolean beginTransaction(XWikiContext context) throws XWikiException
context
- the current XWikiContextXWikiException
- if an error occurs while retrieving or creating a new session and transaction.@Deprecated public boolean beginTransaction(boolean withTransaction, XWikiContext context) throws XWikiException
beginTransaction(SessionFactory, XWikiContext)
withTransaction
- this argument is unusedcontext
- the current XWikiContextXWikiException
- if an error occurs while retrieving or creating a new session and transaction.@Deprecated public boolean beginTransaction(org.hibernate.SessionFactory sfactory, boolean withTransaction, XWikiContext context) throws XWikiException
beginTransaction(SessionFactory, XWikiContext)
sfactory
- the session factory used to begin a new session if none are availablewithTransaction
- this argument is unusedcontext
- the current XWikiContextXWikiException
- if an error occurs while retrieving or creating a new session and transaction.public boolean beginTransaction(org.hibernate.SessionFactory sfactory, XWikiContext inputxcontext) throws XWikiException
sfactory
- the session factory used to begin a new session if none are availableinputxcontext
- the current XWikiContextXWikiException
- if an error occurs while retrieving or creating a new session and transaction.@Deprecated public void endTransaction(XWikiContext context, boolean commit, boolean withTransaction) throws org.hibernate.HibernateException
endTransaction(XWikiContext, boolean)
context
- the current XWikiContextcommit
- should we commit or notwithTransaction
- org.hibernate.HibernateException
public void endTransaction(XWikiContext inputxcontext, boolean commit)
inputxcontext
- the current XWikiContextcommit
- should we commit or notpublic void cleanUp(XWikiContext inputxcontext)
inputxcontext
- public org.hibernate.SessionFactory getSessionFactory()
@Deprecated public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
public org.hibernate.cfg.Configuration getConfiguration()
public org.hibernate.boot.Metadata getMetadata()
@Deprecated public Map<String,String> getConnections()
@Deprecated public int getNbConnections()
@Deprecated public void setNbConnections(int nbConnections)
public String dynamicMappingTableName(String className)
className
- the classname of the object.@Deprecated protected org.hibernate.cfg.Configuration getMapping(String className, String customMapping)
Configuration
containing the provide mapping. Before 4.0M1, this function was called makeMapping.
In 4.0M1, it enter in conflict with makeMapping(String, String)
className
- the classname of the class to map.customMapping
- the custom mappingConfiguration
containing this mapping alone.protected String makeMapping(String className, String customMapping)
className
- the name of the class to map.customMapping
- the custom mapping@Deprecated public <T> T execute(XWikiContext context, boolean bTransaction, boolean doCommit, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
execute(XWikiContext, boolean, HibernateCallback)
or
failSafeExecute(XWikiContext, boolean, HibernateCallback)
context
- - used everywhere.bTransaction
- - should store use old transaction(false) or create new (true)doCommit
- - should store commit changes(if any), or rollback it.cb
- - callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any errorpublic <T> T failSafeExecute(XWikiContext inputxcontext, boolean doCommit, XWikiHibernateBaseStore.HibernateCallback<T> cb)
inputxcontext
- - used everywhere.doCommit
- - should store commit changes(if any), or rollback it.cb
- - callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
, returns null if the callback throw an error.public <T> T execute(XWikiContext inputxcontext, boolean doCommit, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
inputxcontext
- - used everywhere.doCommit
- - should store commit changes(if any), or rollback it.cb
- - callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any error@Deprecated public <T> T executeRead(XWikiContext context, boolean bTransaction, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
executeRead(XWikiContext, HibernateCallback)
or
failSafeExecuteRead(XWikiContext, HibernateCallback)
context
- the current XWikiContextbTransaction
- this argument is unusedcb
- the callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any errorexecute(XWikiContext, boolean, HibernateCallback)
public <T> T failSafeExecuteRead(XWikiContext context, XWikiHibernateBaseStore.HibernateCallback<T> cb)
context
- the current XWikiContextcb
- the callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
, returns null if the callback throw an error.failSafeExecute(XWikiContext, boolean, HibernateCallback)
public <T> T executeRead(XWikiContext context, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
context
- - used everywhere.cb
- - callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any errorexecute(XWikiContext, boolean, HibernateCallback)
@Deprecated public <T> T executeWrite(XWikiContext context, boolean bTransaction, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
executeWrite(XWikiContext, HibernateCallback)
or
failSafeExecuteWrite(XWikiContext, HibernateCallback)
context
- the current XWikiContextbTransaction
- this argument is unusedcb
- the callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any errorexecute(XWikiContext, boolean, HibernateCallback)
public <T> T failSafeExecuteWrite(XWikiContext context, XWikiHibernateBaseStore.HibernateCallback<T> cb)
context
- the current XWikiContextcb
- the callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
execute(XWikiContext, boolean, HibernateCallback)
public <T> T executeWrite(XWikiContext context, XWikiHibernateBaseStore.HibernateCallback<T> cb) throws XWikiException
context
- the current XWikiContextcb
- the callback to executeXWikiHibernateBaseStore.HibernateCallback.doInHibernate(Session)
XWikiException
- if any errorexecute(XWikiContext, boolean, HibernateCallback)
protected boolean isInSchemaMode()
protected org.xwiki.context.Execution getExecution()
public org.hibernate.dialect.Dialect getDialect()
Dialect
Copyright © 2004–2022 XWiki. All rights reserved.