com.isenshi.util.extlib
クラス HSQLDBRDBMSAdapter

java.lang.Object
  拡張org.apache.slide.store.impl.rdbms.AbstractRDBMSAdapter
      拡張org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter
          拡張com.isenshi.util.extlib.HSQLDBRDBMSAdapter
すべての実装インタフェース:
org.apache.slide.store.impl.rdbms.RDBMSAdapter, org.apache.slide.store.impl.rdbms.SequenceAdapter

public class HSQLDBRDBMSAdapter
extends org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter
implements org.apache.slide.store.impl.rdbms.SequenceAdapter

RDBMSAdapter for HSQLDB This expects HSQLDB version 1.8.0 and thus some methods and query might not work on ealier release of HSQLDB.

Points to override StandardRDBMSAdapter.

  1. DELETE SQL Within StandardRDBMSAdapter, DELETE SQL's are issued in the manner like, DELETE TAB1 FROM TAB1 WHERE TAB1.COL1 = ... In this case, HSQLDB reports the error like, Unexpected token TAB1, requires FROM in statement [delete tab1] so, you need to change the SQL as DELETE FROM TAB1 WHERE TAB1.COL1 = ...

    Also, HSQLDB cannot execute the DELETE SQL which has join pattern in where clause like, (although this looks to work in PostgreSQL, see PostgreSQLRDBMSAdapter) DELETE TAB1 FROM TAB1.COL1 = TAB2.COL1 AND TAB2.COL2 = TAB3.COL2 AND... The error message reported in above is very, very, very confusing, becase it says like Column not found: COLNAME in statement although the column "COLNAME" exists properly. I observed this intermittently. Apparently, if the data matching to the condition exists, it tends to report this error. Here, to avoid this, DELETE TAB1 FROM TAB1.COL1 IN (SELECT TAB2.COL1 FROM TAB2,TAB3 WHERE TAB2.COLS2 = TAB3.COL2 ...

  2. Function Some function calls seems to be different from standard one. org.hsqldb.Library includes collect manner of functions available in HSQLDB Also, FAQ (http://hsqldb.org/web/hsqlFAQ.html#STORED) might help you.

Implements SequenceAdapter If #isSequenceSupported returns false, throws Exception, so it might be better to implements SequenceAdapter.

作成者:
someda

フィールドの概要
 
クラス org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter から継承したフィールド
bcompress, LOG_CHANNEL
 
クラス org.apache.slide.store.impl.rdbms.AbstractRDBMSAdapter から継承したフィールド
logger, service
 
コンストラクタの概要
HSQLDBRDBMSAdapter(org.apache.slide.common.Service service, org.apache.slide.util.logger.Logger logger)
           
 
メソッドの概要
protected  void clearBinding(Connection connection, org.apache.slide.common.Uri uri)
           
protected  String convertRevisionNumberToComparable(String revisionNumber)
           Determines sorting order from VERSION_HISTORY table by its REVISION_NO column.
 boolean createSequence(Connection conn, String sequenceName)
           
 boolean isSequenceSupported(Connection conn)
           
static int majorVersion(String revisionNumber)
          For HSQLDB sorting by int order.
static int minorVersion(String revisionNumber)
          For HSQLDB sorting by int order.
 long nextSequenceValue(Connection conn, String sequenceName)
           
protected static String normalizeSequenceName(String sequenceName)
           
 void removeLock(Connection connection, org.apache.slide.common.Uri uri, org.apache.slide.lock.NodeLock lock)
           
 void removeObject(Connection connection, org.apache.slide.common.Uri uri, org.apache.slide.structure.ObjectNode object)
           
 void removeRevisionContent(Connection connection, org.apache.slide.common.Uri uri, org.apache.slide.content.NodeRevisionDescriptor revisionDescriptor)
           
 void removeRevisionDescriptor(Connection connection, org.apache.slide.common.Uri uri, org.apache.slide.content.NodeRevisionNumber revisionNumber)
           
 void removeRevisionDescriptors(Connection connection, org.apache.slide.common.Uri uri)
           
 void revokePermission(Connection connection, org.apache.slide.common.Uri uri, org.apache.slide.security.NodePermission permission)
           
 void revokePermissions(Connection connection, org.apache.slide.common.Uri uri)
           
 boolean sequenceExists(Connection conn, String sequenceName)
           
static int weightedVersion(String revisionNumber)
          Spliting revisionNumber by revision delimiter (".") and returns weighted integer which is addition of each elements multiplied with the corresponding weights.
 
クラス org.apache.slide.store.impl.rdbms.StandardRDBMSAdapter から継承したメソッド
assureBranchId, assureLabelId, assureUriId, assureVersionInfo, close, close, createException, createObject, createRevisionContent, createRevisionDescriptor, createRevisionDescriptors, enumerateLocks, enumeratePermissions, getRevisionNumberAsString, grantPermission, killLock, putLock, renewLock, retrieveObject, retrieveRevisionContent, retrieveRevisionDescriptor, retrieveRevisionDescriptors, setParameters, storeContent, storeObject, storeObject, storeRevisionContent, storeRevisionContent, storeRevisionDescriptor, storeRevisionDescriptors
 
クラス org.apache.slide.store.impl.rdbms.AbstractRDBMSAdapter から継承したメソッド
getLogger
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

HSQLDBRDBMSAdapter

public HSQLDBRDBMSAdapter(org.apache.slide.common.Service service,
                          org.apache.slide.util.logger.Logger logger)
メソッドの詳細

removeObject

public void removeObject(Connection connection,
                         org.apache.slide.common.Uri uri,
                         org.apache.slide.structure.ObjectNode object)
                  throws org.apache.slide.common.ServiceAccessException,
                         org.apache.slide.structure.ObjectNotFoundException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の removeObject
例外:
org.apache.slide.common.ServiceAccessException
org.apache.slide.structure.ObjectNotFoundException

removeRevisionContent

public void removeRevisionContent(Connection connection,
                                  org.apache.slide.common.Uri uri,
                                  org.apache.slide.content.NodeRevisionDescriptor revisionDescriptor)
                           throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の removeRevisionContent
例外:
org.apache.slide.common.ServiceAccessException

removeRevisionDescriptor

public void removeRevisionDescriptor(Connection connection,
                                     org.apache.slide.common.Uri uri,
                                     org.apache.slide.content.NodeRevisionNumber revisionNumber)
                              throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の removeRevisionDescriptor
例外:
org.apache.slide.common.ServiceAccessException

removeRevisionDescriptors

public void removeRevisionDescriptors(Connection connection,
                                      org.apache.slide.common.Uri uri)
                               throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の removeRevisionDescriptors
例外:
org.apache.slide.common.ServiceAccessException

removeLock

public void removeLock(Connection connection,
                       org.apache.slide.common.Uri uri,
                       org.apache.slide.lock.NodeLock lock)
                throws org.apache.slide.common.ServiceAccessException,
                       org.apache.slide.lock.LockTokenNotFoundException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の removeLock
例外:
org.apache.slide.common.ServiceAccessException
org.apache.slide.lock.LockTokenNotFoundException

revokePermission

public void revokePermission(Connection connection,
                             org.apache.slide.common.Uri uri,
                             org.apache.slide.security.NodePermission permission)
                      throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の revokePermission
例外:
org.apache.slide.common.ServiceAccessException

revokePermissions

public void revokePermissions(Connection connection,
                              org.apache.slide.common.Uri uri)
                       throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.RDBMSAdapter 内の revokePermissions
例外:
org.apache.slide.common.ServiceAccessException

clearBinding

protected void clearBinding(Connection connection,
                            org.apache.slide.common.Uri uri)
                     throws org.apache.slide.common.ServiceAccessException,
                            org.apache.slide.structure.ObjectNotFoundException,
                            SQLException
例外:
org.apache.slide.common.ServiceAccessException
org.apache.slide.structure.ObjectNotFoundException
SQLException

convertRevisionNumberToComparable

protected String convertRevisionNumberToComparable(String revisionNumber)

Determines sorting order from VERSION_HISTORY table by its REVISION_NO column.

As the type of REVISION_NO is VARCHAR, the default ordering rule doesn't provide desirable results. For example, we have 11 nodes, revisioned from 1.0 to 1.10. Under the default rule, the node 1.10 comes earlier than node 1.2. (here the number before dot is called "major", and one after dot called "minor")

StandardRDBMSAdapter#convertRevisionNumberToComparable uses convert function, though HSQLDB doesn't have it (see org.hsqldb.Library), thus here needed to override that method.

First, you can get this by the following mannger,

major = "java.lang.Integer.parseInt"(TRIM(TRAILING '.' FROM SUBSTRING(vh.REVISION_NO,1,LOCATE('.',vh.REVISION_NO))))
minor = "java.lang.Integer.parseInt"(SUBSTRING(vh.REVISION_NO,LOCATE('.',vh.REVISION_NO)+1))
This looks complicated, especially the first one uses 4 methods!!
  1. parseInt
    needed for numerical sort, TRIM and SUBSTRING returs String object. if not specified, its result will be same as the case without using functions.
  2. TRIM (its argument specification itself seems complicated ...)
    needed to remove the dot of the string of SUBSTRING returns. SUBSTRING argument type is (String, int, Integer) thus, you couldn't specify SUBSTRING(vh.REVISION_NO,1,LOCATE('.',vh.REVISION_NO)-1).
  3. SUBSTRING
    needed to separate revision number.
  4. LOCATE
    needed for to know the index of dot.

Thus, custom 2 simple methods are used, majorVersion and minorVersion defined in this class.

関連項目:
StandardRDBMSAdapter.retrieveRevisionDescriptors(java.sql.Connection, org.apache.slide.common.Uri)

normalizeSequenceName

protected static String normalizeSequenceName(String sequenceName)

isSequenceSupported

public boolean isSequenceSupported(Connection conn)
定義:
インタフェース org.apache.slide.store.impl.rdbms.SequenceAdapter 内の isSequenceSupported

createSequence

public boolean createSequence(Connection conn,
                              String sequenceName)
                       throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.SequenceAdapter 内の createSequence
例外:
org.apache.slide.common.ServiceAccessException

nextSequenceValue

public long nextSequenceValue(Connection conn,
                              String sequenceName)
                       throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.SequenceAdapter 内の nextSequenceValue
例外:
org.apache.slide.common.ServiceAccessException

sequenceExists

public boolean sequenceExists(Connection conn,
                              String sequenceName)
                       throws org.apache.slide.common.ServiceAccessException
定義:
インタフェース org.apache.slide.store.impl.rdbms.SequenceAdapter 内の sequenceExists
例外:
org.apache.slide.common.ServiceAccessException

majorVersion

public static int majorVersion(String revisionNumber)
For HSQLDB sorting by int order. Extracts major version number from whole revision number, like returns 1 for "1.3".

パラメータ:
revisionNumber - must contains "." to separate here, and also expects %d.%d style.
戻り値:
major version of revisionNumber
例外:
IllegalAugumentException - if revisionNumber doesn't contains ".".
NumberFormatException - if extracted string before "." doesn't decimal string.

minorVersion

public static int minorVersion(String revisionNumber)
For HSQLDB sorting by int order. Extracts major version number from whole revision number, like returns 3 for "1.3". Also, revision number is expected as %d.%d style, not %d.%d.%d, that is, for "1.3.3", this throws NumberFormatException because "3.3" can't be formated as integer.

パラメータ:
revisionNumber - must contains "." to separate here, and also expects %d.%d style.
戻り値:
major version of revisionNumber
例外:
IllegalAugumentException - if revisionNumber doesn't contains ".".
NumberFormatException - if extracted string before "." doesn't decimal string.

weightedVersion

public static int weightedVersion(String revisionNumber)
Spliting revisionNumber by revision delimiter (".") and returns weighted integer which is addition of each elements multiplied with the corresponding weights. In branching, revisionNumber become to have sub branch version, like, 1.3 to 1.3.0 or 1.3.0.1, and so on. Spliting 2 parts of revisionNumber by "." works well for 1.3, doesn't for 1.3.0.1.

パラメータ:
revisionNumber - up to 10-depth supported (like 1.1.1.1.1.1.1.1.1.1)
戻り値:
weighted version integer for given revisionNumber
例外:
IllegalStateException - if revisionNumber exceeds the support limit depth of branch.
関連項目:
ASF Bugzilla Bug 37254 RDBMS store and Branching.


Copyright © 2005-2006 The Seasar Foundation and the others.. All Rights Reserved.