2.17.2: 2011-06-17

net.sf.basedb.core
Class PredefinedQuery

java.lang.Object
  extended by 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
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 Logger log
          Log core events.
 
Constructor Summary
PredefinedQuery()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
Log core events.


commonDom

private static Document commonDom
Holds the XML document containing the common queries.


dialectDom

private static Document dialectDom
Holds the XML document containing the dialect-specific queries.


commonQueryFile

private static final String commonQueryFile
The path to the query file with common queries.

See Also:
Constant Field Values

dialectQueryFile

private static String dialectQueryFile
The path to the query file with dialect-specific queries.


dtdFile

private static final URL dtdFile
The DTD which is used to validate the XML file.


isInitialised

private static boolean isInitialised
Constructor Detail

PredefinedQuery

public PredefinedQuery()
Method Detail

init

static void init()
          throws BaseException
Load and parse the file with predefined queries.

Throws:
BaseException

unload

static void unload()
Unload all settings.


getQueryString

public static String getQueryString(String name,
                                    String... replacements)
                             throws BaseException
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

2.17.2: 2011-06-17