Package net.sf.basedb.core
Class PredefinedQuery
java.lang.Object
net.sf.basedb.core.PredefinedQuery
public class PredefinedQuery extends Object
This class is used for reading XML files with information
about predefined queries. The file should be located at the path
returned by
Application.getQueryFile
.
The format of the XML file is forced by a DTD. In summary:
<?xml version="1.0" ?> <!DOCTYPE predefined-queries SYSTEM "predefined.dtd" > <predefined-queries> <query id="GET_GROUPS_FOR_USER" type="HQL"> <sql> SELECT ug.groupId FROM UserGroups ug WHERE ug.userId = :user_id </sql> <description> Loads the group ID for all groups where the user is a member </description> </query> </predefined-queries>
- Version:
- 2.0, 2.13 (made public)
- Author:
- Nicklas
-
Field Summary
Fields Modifier and Type Field Description private static Document
commonDom
Holds the XML document containing the common queries.private static String
commonQueryFile
The path to the query file with common queries.private static Document
dialectDom
Holds the XML document containing the dialect-specific queries.private static String
dialectQueryFile
The path to the query file with dialect-specific queries.private static URL
dtdFile
The DTD which is used to validate the XML file.private static boolean
isInitialised
private static org.slf4j.Logger
log
Log core events. -
Constructor Summary
Constructors Constructor Description PredefinedQuery()
-
Method Summary
Modifier and Type Method Description static String
getQueryString(String name, String... replacements)
Get the query string for the predefined query with the specified name.(package private) static void
init()
Load and parse the file with predefined queries.(package private) static void
unload()
Unload all settings.
-
Field Details
-
log
private static final org.slf4j.Logger logLog core events. -
commonDom
Holds the XML document containing the common queries. -
dialectDom
Holds the XML document containing the dialect-specific queries. -
commonQueryFile
The path to the query file with common queries.- See Also:
- Constant Field Values
-
dialectQueryFile
The path to the query file with dialect-specific queries. -
dtdFile
The DTD which is used to validate the XML file. -
isInitialised
private static boolean isInitialised
-
-
Constructor Details
-
PredefinedQuery
public PredefinedQuery()
-
-
Method Details
-
init
Load and parse the file with predefined queries.- Throws:
BaseException
-
unload
static void unload()Unload all settings. -
getQueryString
Get the query string for the predefined query with the specified name. This method was made public in BASE 2.13.- Throws:
BaseException
- If the query is not found or there is any other error- Since:
- 2.13
-