KFS data access objects (DAOs) utilize OJB for most database operations. OJB has built-in support for several different database platforms, so we start by leveraging that. There are places, though, where we need functionality not provided by OJB (or that OJB does not perform quickly or easily enough). For DAOs which contain direct SQL (via JDBC statements), you will find that these statements will be subclasses of the PlatformAwareDaoBaseJdbc class.
KFS has the concept of the database platform for those cases where we were unable to rely on OJB and the supported databases deviate. This is represented by the org.kuali.rice.core.database.platform.DatabasePlatform
interface. There are currently two primary implementations of this interface: org.kuali.rice.core.database.platform.OracleDatabasePlatform
and org.kuali.rice.core.database.platform.MySQLDatabasePlatform
. These classes provide information and functionality used by other parts of the application to compensate for differences between the two platforms. As you are developing your own DAOs, you may need to use the DatabasePlatform
methods. As long as your DAO subclasses org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb
or org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseJdbc
as the KFS DAOs do, you can use the getDbPlatform()
method of the super class to obtain the configured instance of DatabasePlatform
. You can also obtain the DatabasePlatform
object as needed by calling NSServiceLocator.getDatabasePlatform()
.
KFS can be adapted to work with other databases by adding appropriate DatabasePlatform
implementations. Adding support for other databases may uncover the need for additional methods on this interface.
If you use Oracle or MySQL, platform-related settings will be taken care of for you at build time, based on the value of the datasource.ojb.platform
property in kfs-build.properties
. The build script uses this property to configure OJB and determine the appropriate driver, JDBC URL, and DatabasePlatform
implementation to use. If you choose to add support for another database platform, you will also want to review and supplement this build logic.
There are also special classes for OJB's handling of sequences. Since MySQL does not have sequences, we had to implement a subclass of OJB's SequenceManager
: org.apache.ojb.broker.platforms.KualiMySQLSequenceManagerImpl
which will be used if you configure a MySQL database. If you will be using a non Oracle or MySQL database, you will need to set the datasource.ojb.sequence.manager
configuration property to the appropriate value.
Include Page | ||||
---|---|---|---|---|
|