com.xpn.xwiki.store
Class XWikiHibernateStore

java.lang.Object
  extended by com.xpn.xwiki.store.XWikiHibernateBaseStore
      extended by com.xpn.xwiki.store.XWikiHibernateStore
All Implemented Interfaces:
XWikiStoreInterface, org.xwiki.component.phase.Initializable

@Component
@Named(value="hibernate")
@Singleton
public class XWikiHibernateStore
extends XWikiHibernateBaseStore
implements XWikiStoreInterface

The XWiki Hibernate database driver.

Version:
$Id: a98e5b8f1091096c121b7bd12c65c062936a71cd $

Nested Class Summary
 
Nested classes/interfaces inherited from class com.xpn.xwiki.store.XWikiHibernateBaseStore
XWikiHibernateBaseStore.HibernateCallback<T>
 
Field Summary
 
Fields inherited from class com.xpn.xwiki.store.XWikiHibernateBaseStore
loggerManager
 
Constructor Summary
XWikiHibernateStore()
          Empty constructor needed for component manager.
XWikiHibernateStore(String hibpath)
          Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.
XWikiHibernateStore(XWikiContext context)
          Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.
XWikiHibernateStore(XWiki xwiki, XWikiContext context)
          Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.
 
Method Summary
 int countDocuments(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
          API allowing to count the total number of documents that would be returned by a parameterized query.
 int countDocuments(String wheresql, XWikiContext context)
          API allowing to count the total number of documents that would be returned by a query.
protected  String createSQLQuery(String queryPrefix, String whereSQL)
           
 void createWiki(String wikiName, XWikiContext context)
          Allows to create a new wiki database and initialize the default tables.
 void deleteLinks(long docId, XWikiContext context, boolean bTransaction)
           
 void deleteLock(XWikiLock lock, XWikiContext context, boolean bTransaction)
           
 void deleteWiki(String wikiName, XWikiContext context)
          Delete a wiki database.
 void deleteXWikiCollection(BaseCollection object, XWikiContext context, boolean bTransaction, boolean evict)
          Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.
 void deleteXWikiDoc(XWikiDocument doc, XWikiContext context)
           
protected  void executeDeleteWikiStatement(Statement statement, DatabaseProduct databaseProduct, String escapedSchemaName)
          Execute the SQL statement on the database to remove a wiki.
 boolean exists(XWikiDocument doc, XWikiContext context)
          Verifies if a wiki document exists
 List<String> getClassList(XWikiContext context)
           
protected  String getColumnsForSelectStatement(String whereSQL)
           
 void getContent(XWikiDocument doc, StringBuffer buf)
           
 List<String> getCustomMappingPropertyList(BaseClass bclass)
           
 QueryManager getQueryManager()
           
 List<String> getTranslationList(XWikiDocument doc, XWikiContext context)
           
 void initialize()
           
 boolean injectCustomMapping(BaseClass doc1class, XWikiContext context)
           
 boolean injectCustomMapping(String className, String custommapping, XWikiContext context)
           
 void injectCustomMappings(XWikiContext context)
           
 boolean injectCustomMappings(XWikiDocument doc, XWikiContext context)
           
 org.hibernate.SessionFactory injectCustomMappingsInSessionFactory(BaseClass bclass, XWikiContext context)
           
 org.hibernate.SessionFactory injectCustomMappingsInSessionFactory(XWikiContext context)
           
 void injectUpdatedCustomMappings(XWikiContext context)
           
 boolean isCustomMappingValid(BaseClass bclass, String custommapping1, XWikiContext context)
           
 boolean isWikiNameAvailable(String wikiName, XWikiContext context)
          Indicate if the provided wiki name could be used to create a new wiki.
 List<DocumentReference> loadBacklinks(DocumentReference documentReference, boolean bTransaction, XWikiContext context)
           
 List<String> loadBacklinks(String fullName, XWikiContext context, boolean bTransaction)
          Deprecated. since 2.2M2 use loadBacklinks(DocumentReference, boolean, XWikiContext)
 List<XWikiLink> loadLinks(long docId, XWikiContext context, boolean bTransaction)
           
 XWikiLock loadLock(long docId, XWikiContext context, boolean bTransaction)
           
 void loadXWikiCollection(BaseCollection object, XWikiContext context, boolean bTransaction)
          Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.
 XWikiDocument loadXWikiDoc(XWikiDocument doc, XWikiContext context)
           
 void saveLinks(XWikiDocument doc, XWikiContext context, boolean bTransaction)
           
 void saveLock(XWikiLock lock, XWikiContext context, boolean bTransaction)
           
 void saveXWikiCollection(BaseCollection object, XWikiContext context, boolean bTransaction)
          Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.
 void saveXWikiDoc(XWikiDocument doc, XWikiContext context)
           
 void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTransaction)
           
 List search(org.hibernate.Query query, int nb, int start, XWikiContext context)
           
<T> List<T>
search(String sql, int nb, int start, List<?> parameterValues, XWikiContext context)
          Execute a reading request with parameters and return result.
<T> List<T>
search(String sql, int nb, int start, Object[][] whereParams, List<?> parameterValues, XWikiContext context)
          Execute a reading request with parameters and return result.
<T> List<T>
search(String sql, int nb, int start, Object[][] whereParams, XWikiContext context)
          Execute a reading request and return result.
<T> List<T>
search(String sql, int nb, int start, XWikiContext context)
          Execute a reading request and return result.
 List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents by passing HQL where clause values as parameters.
 List<DocumentReference> searchDocumentReferences(String wheresql, int nb, int start, String selectColumns, XWikiContext context)
           
 List<DocumentReference> searchDocumentReferences(String wheresql, int nb, int start, XWikiContext context)
           
 List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
          Same as XWikiStoreInterface.searchDocumentReferences(String, int, int, List, XWikiContext) but returns all rows.
 List<DocumentReference> searchDocumentReferences(String wheresql, XWikiContext context)
           
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, boolean checkRight, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, boolean checkRight, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, XWikiContext context)
          Search documents in the storing system.
 List<String> searchDocumentsNames(String parametrizedSqlClause, int nb, int start, List<?> parameterValues, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, int nb, int start, String selectColumns, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, int nb, int start, XWikiContext context)
           
 List<String> searchDocumentsNames(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, XWikiContext context)
           
 
Methods inherited from class com.xpn.xwiki.store.XWikiHibernateBaseStore
beginTransaction, beginTransaction, beginTransaction, beginTransaction, checkHibernate, cleanUp, dynamicMappingTableName, endTransaction, endTransaction, escapeSchema, execute, execute, executeRead, executeRead, executeWrite, executeWrite, failSafeExecute, failSafeExecuteRead, failSafeExecuteWrite, getConfiguration, getConnections, getDatabaseProductName, getDatabaseProductName, getMapping, getNbConnections, getPath, getSchemaFromWikiName, getSchemaFromWikiName, getSchemaFromWikiName, getSchemaUpdateScript, getSession, getSessionFactory, getTransaction, isInSchemaMode, isVirtual, makeMapping, setDatabase, setNbConnections, setPath, setSession, setSessionFactory, setTransaction, shutdownHibernate, updateSchema, updateSchema, updateSchema, updateSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.xpn.xwiki.store.XWikiStoreInterface
cleanUp
 

Constructor Detail

XWikiHibernateStore

@Deprecated
public XWikiHibernateStore(XWiki xwiki,
                                      XWikiContext context)
Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.

This allows to initialize our storage engine. The hibernate config file path is taken from xwiki.cfg or directly in the WEB-INF directory.

Parameters:
xwiki -
context -

XWikiHibernateStore

@Deprecated
public XWikiHibernateStore(String hibpath)
Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.

Initialize the storage engine with a specific path. This is used for tests.

Parameters:
hibpath -

XWikiHibernateStore

@Deprecated
public XWikiHibernateStore(XWikiContext context)
Deprecated. 1.6M1. Use ComponentManager.lookup(XWikiStoreInterface.class) instead.

See Also:
XWikiHibernateStore(XWiki, XWikiContext)

XWikiHibernateStore

public XWikiHibernateStore()
Empty constructor needed for component manager.

Method Detail

initialize

public void initialize()
                throws org.xwiki.component.phase.InitializationException
Specified by:
initialize in interface org.xwiki.component.phase.Initializable
Overrides:
initialize in class XWikiHibernateBaseStore
Throws:
org.xwiki.component.phase.InitializationException

isWikiNameAvailable

public boolean isWikiNameAvailable(String wikiName,
                                   XWikiContext context)
                            throws XWikiException
Description copied from interface: XWikiStoreInterface
Indicate if the provided wiki name could be used to create a new wiki.

Specified by:
isWikiNameAvailable in interface XWikiStoreInterface
Parameters:
wikiName - the name of the wiki.
context - the XWiki context.
Returns:
true if the name is already used, false otherwise.
Throws:
XWikiException - error when looking if wiki name already used.

createWiki

public void createWiki(String wikiName,
                       XWikiContext context)
                throws XWikiException
Description copied from interface: XWikiStoreInterface
Allows to create a new wiki database and initialize the default tables.

Specified by:
createWiki in interface XWikiStoreInterface
Parameters:
wikiName - the name of the new wiki.
context - the XWiki context.
Throws:
XWikiException - error when creating new wiki.

deleteWiki

public void deleteWiki(String wikiName,
                       XWikiContext context)
                throws XWikiException
Description copied from interface: XWikiStoreInterface
Delete a wiki database.

Specified by:
deleteWiki in interface XWikiStoreInterface
Parameters:
wikiName - the name of the wiki.
context - the XWiki context.
Throws:
XWikiException - error when deleting wiki database.

executeDeleteWikiStatement

protected void executeDeleteWikiStatement(Statement statement,
                                          DatabaseProduct databaseProduct,
                                          String escapedSchemaName)
                                   throws SQLException
Execute the SQL statement on the database to remove a wiki.

Parameters:
statement - the statement object on which to execute the wiki deletion
databaseProduct - the database type
escapedSchemaName - the subwiki schema name being deleted
Throws:
SQLException - in case of an error while deleting the sub wiki

exists

public boolean exists(XWikiDocument doc,
                      XWikiContext context)
               throws XWikiException
Verifies if a wiki document exists

Specified by:
exists in interface XWikiStoreInterface
Parameters:
doc -
context -
Throws:
XWikiException

saveXWikiDoc

public void saveXWikiDoc(XWikiDocument doc,
                         XWikiContext context,
                         boolean bTransaction)
                  throws XWikiException
Specified by:
saveXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

saveXWikiDoc

public void saveXWikiDoc(XWikiDocument doc,
                         XWikiContext context)
                  throws XWikiException
Specified by:
saveXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

loadXWikiDoc

public XWikiDocument loadXWikiDoc(XWikiDocument doc,
                                  XWikiContext context)
                           throws XWikiException
Specified by:
loadXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

deleteXWikiDoc

public void deleteXWikiDoc(XWikiDocument doc,
                           XWikiContext context)
                    throws XWikiException
Specified by:
deleteXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

saveXWikiCollection

@Deprecated
public void saveXWikiCollection(BaseCollection object,
                                           XWikiContext context,
                                           boolean bTransaction)
                         throws XWikiException
Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.

Throws:
XWikiException

loadXWikiCollection

@Deprecated
public void loadXWikiCollection(BaseCollection object,
                                           XWikiContext context,
                                           boolean bTransaction)
                         throws XWikiException
Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.

Throws:
XWikiException

deleteXWikiCollection

@Deprecated
public void deleteXWikiCollection(BaseCollection object,
                                             XWikiContext context,
                                             boolean bTransaction,
                                             boolean evict)
                           throws XWikiException
Deprecated. This is internal to XWikiHibernateStore and may be removed in the future.

Throws:
XWikiException

loadLock

public XWikiLock loadLock(long docId,
                          XWikiContext context,
                          boolean bTransaction)
                   throws XWikiException
Specified by:
loadLock in interface XWikiStoreInterface
Throws:
XWikiException

saveLock

public void saveLock(XWikiLock lock,
                     XWikiContext context,
                     boolean bTransaction)
              throws XWikiException
Specified by:
saveLock in interface XWikiStoreInterface
Throws:
XWikiException

deleteLock

public void deleteLock(XWikiLock lock,
                       XWikiContext context,
                       boolean bTransaction)
                throws XWikiException
Specified by:
deleteLock in interface XWikiStoreInterface
Throws:
XWikiException

loadLinks

public List<XWikiLink> loadLinks(long docId,
                                 XWikiContext context,
                                 boolean bTransaction)
                          throws XWikiException
Specified by:
loadLinks in interface XWikiStoreInterface
Throws:
XWikiException

loadBacklinks

public List<DocumentReference> loadBacklinks(DocumentReference documentReference,
                                             boolean bTransaction,
                                             XWikiContext context)
                                      throws XWikiException
Specified by:
loadBacklinks in interface XWikiStoreInterface
Throws:
XWikiException

loadBacklinks

@Deprecated
public List<String> loadBacklinks(String fullName,
                                             XWikiContext context,
                                             boolean bTransaction)
                           throws XWikiException
Deprecated. since 2.2M2 use loadBacklinks(DocumentReference, boolean, XWikiContext)

Specified by:
loadBacklinks in interface XWikiStoreInterface
Throws:
XWikiException

saveLinks

public void saveLinks(XWikiDocument doc,
                      XWikiContext context,
                      boolean bTransaction)
               throws XWikiException
Specified by:
saveLinks in interface XWikiStoreInterface
Throws:
XWikiException

deleteLinks

public void deleteLinks(long docId,
                        XWikiContext context,
                        boolean bTransaction)
                 throws XWikiException
Specified by:
deleteLinks in interface XWikiStoreInterface
Throws:
XWikiException

getContent

public void getContent(XWikiDocument doc,
                       StringBuffer buf)

getClassList

public List<String> getClassList(XWikiContext context)
                          throws XWikiException
Specified by:
getClassList in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause,
                                                        List<?> parameterValues,
                                                        XWikiContext context)
                                                 throws XWikiException
Description copied from interface: XWikiStoreInterface
Same as XWikiStoreInterface.searchDocumentReferences(String, int, int, List, XWikiContext) but returns all rows.

Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException
See Also:
XWikiStoreInterface.searchDocumentReferences(String, int, int, java.util.List, com.xpn.xwiki.XWikiContext)

searchDocumentsNames

public List<String> searchDocumentsNames(String parametrizedSqlClause,
                                         List<?> parameterValues,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause,
                                                        int nb,
                                                        int start,
                                                        List<?> parameterValues,
                                                        XWikiContext context)
                                                 throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Example

 <code>
 #set($orphans = $xwiki.searchDocuments(" where doc.fullName <> ? and (doc.parent = ? or "
     + "(doc.parent = ? and doc.space = ?))",
     ["${doc.fullName}as", ${doc.fullName}, ${doc.name}, ${doc.space}]))
 </code>
 

Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Parameters:
parametrizedSqlClause - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))"
nb - the number of rows to return. If 0 then all rows are returned
start - the number of rows to skip. If 0 don't skip any row
parameterValues - the where clause values that replace the question marks (?)
context - the XWiki context required for getting information about the execution context
Returns:
a list of document references
Throws:
XWikiException - in case of error while performing the query

searchDocumentsNames

public List<String> searchDocumentsNames(String parametrizedSqlClause,
                                         int nb,
                                         int start,
                                         List<?> parameterValues,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        int nb,
                                                        int start,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         int nb,
                                         int start,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        int nb,
                                                        int start,
                                                        String selectColumns,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         int nb,
                                         int start,
                                         String selectColumns,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request and return result.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          List<?> parameterValues,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request with parameters and return result.

Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          Object[][] whereParams,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request and return result.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
whereParams - if not null add to sql a where clause based on a table of table containing field name, field value and compared symbol ("=", ">", etc.).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          Object[][] whereParams,
                          List<?> parameterValues,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request with parameters and return result.

Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
whereParams - if not null add to sql a where clause based on a table of table containing field name, field value and compared symbol ("=", ">", etc.).
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public List search(org.hibernate.Query query,
                   int nb,
                   int start,
                   XWikiContext context)
            throws XWikiException
Throws:
XWikiException

countDocuments

public int countDocuments(String wheresql,
                          XWikiContext context)
                   throws XWikiException
Description copied from interface: XWikiStoreInterface
API allowing to count the total number of documents that would be returned by a query.

Specified by:
countDocuments in interface XWikiStoreInterface
Parameters:
wheresql - Query to use, similar to the ones accepted by XWikiStoreInterface.searchDocuments(String, XWikiContext). It should not contain order by or group clauses, since this kind of queries are not portable.
context - The current request context.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

countDocuments

public int countDocuments(String parametrizedSqlClause,
                          List<?> parameterValues,
                          XWikiContext context)
                   throws XWikiException
Description copied from interface: XWikiStoreInterface
API allowing to count the total number of documents that would be returned by a parameterized query.

Specified by:
countDocuments in interface XWikiStoreInterface
Parameters:
parametrizedSqlClause - Parameterized query to use, similar to the ones accepted by XWikiStoreInterface.searchDocuments(String, List, XWikiContext). It should not contain order by or group clauses, since this kind of queries are not portable.
parameterValues - The parameter values that replace the question marks.
context - The current request context.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           boolean checkRight,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
checkRight - if true check for each found document if context's user has "view" rights for it.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           boolean checkRight,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
checkRight - if true check for each found document if context's user has "view" rights for it.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

createSQLQuery

protected String createSQLQuery(String queryPrefix,
                                String whereSQL)
Parameters:
queryPrefix - the start of the SQL query (for example "select distinct doc.space, doc.name")
whereSQL - the where clause to append
Returns:
the full formed SQL query, to which the order by columns have been added as returned columns (this is required for example for HSQLDB).

getColumnsForSelectStatement

protected String getColumnsForSelectStatement(String whereSQL)
Parameters:
whereSQL - the SQL where clause
Returns:
the list of columns to return in the select clause as a string starting with ", " if there are columns or an empty string otherwise. The returned columns are extracted from the where clause. One reason for doing so is because HSQLDB only support SELECT DISTINCT SQL statements where the columns operated on are returned from the query.

isCustomMappingValid

public boolean isCustomMappingValid(BaseClass bclass,
                                    String custommapping1,
                                    XWikiContext context)
Specified by:
isCustomMappingValid in interface XWikiStoreInterface

injectCustomMappings

public void injectCustomMappings(XWikiContext context)
                          throws XWikiException
Specified by:
injectCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

injectUpdatedCustomMappings

public void injectUpdatedCustomMappings(XWikiContext context)
                                 throws XWikiException
Specified by:
injectUpdatedCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

injectCustomMappingsInSessionFactory

public org.hibernate.SessionFactory injectCustomMappingsInSessionFactory(BaseClass bclass,
                                                                         XWikiContext context)
                                                                  throws XWikiException
Throws:
XWikiException

injectCustomMappingsInSessionFactory

public org.hibernate.SessionFactory injectCustomMappingsInSessionFactory(XWikiContext context)
                                                                  throws XWikiException
Throws:
XWikiException

injectCustomMappings

public boolean injectCustomMappings(XWikiDocument doc,
                                    XWikiContext context)
                             throws XWikiException
Specified by:
injectCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

injectCustomMapping

public boolean injectCustomMapping(String className,
                                   String custommapping,
                                   XWikiContext context)
                            throws XWikiException
Parameters:
className - the name of the class to map
custommapping - the custom mapping to inject for this class
context - the current XWikiContext
Returns:
a boolean indicating if the mapping has been added to the current hibernate configuration, and a reload of the factory is required.
Throws:
XWikiException - if an error occurs
Since:
4.0M1

injectCustomMapping

public boolean injectCustomMapping(BaseClass doc1class,
                                   XWikiContext context)
                            throws XWikiException
Specified by:
injectCustomMapping in interface XWikiStoreInterface
Throws:
XWikiException

getCustomMappingPropertyList

public List<String> getCustomMappingPropertyList(BaseClass bclass)
Specified by:
getCustomMappingPropertyList in interface XWikiStoreInterface

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

getTranslationList

public List<String> getTranslationList(XWikiDocument doc,
                                       XWikiContext context)
                                throws XWikiException
Specified by:
getTranslationList in interface XWikiStoreInterface
Throws:
XWikiException

getQueryManager

public QueryManager getQueryManager()
Specified by:
getQueryManager in interface XWikiStoreInterface
Returns:
QueryManager used for creating queries to store. Use QueryManager instead of #search* methods because it is more abstract from store implementation and support multiple query languages.


Copyright © 2004-2013 XWiki. All Rights Reserved.