Database, Persistence Layer, Free-Text Search & Versioning

CATE is based on a MySQL database, although being hibernate based, it could use a different database server if such a thing was neccessary (in theory). The database schema is generated by hibernate initially, although hbm2ddl does not map columns properly, and these have had to be tweaked by hand. The ddl files for generating a blank database can be found in cate-server/root/data/*.ddl, where 001_cate.ddl generates the main tables, and 002_jbpm.ddl generates the tables for jBPM. 003_acl.ddl is the schema for Spring Security's Access Control List implementation (not currently used).

The persistence layer uses a patched version of hibernate 3.4.0 (there is an outstanding bug in the trunk of hibernate relating to subselects that renders hibernate-envers unusable). Hibernate configuration files live in cate-model/src/main/resources/org/cateproject/model/hibernate.cfg.xml with the properties file being found in WEB-INF/classes (i.e. in the root of the classpath). The properties in the hibernate.properties file are also picked up by the spring application context (using PropertyPlaceholderConfigurer) and are added to other beans, like the datasource. CATE currently uses the Apache commons Database Connection Pool component.

Almost all of the persistence and service layer is based on the EDIT Common Data Model Java Library (currently about to be released as version 2.1, although not in their maven repository just yet). In addition, CATE has a couple of DAO's that act as a facade over SOAP services, using apache axis (consequently, the CATE web application needs to be allowed to make outgoing network connections to the Biodiversity Heritage Library, and to Genbank). It is likely that these components will be turned into generic components and committed to the EDIT repository in the medium term. There are also a couple of DAO's specific to CATE, to handle the persistence of jBPM tasks and processes, which the CDM doesn't cover.

The CDM uses the hibernate-search library to provide free-text searching functionality. This library integrates the apache Lucene search API with hibernate, and creates lucene indices (files) that are synchronized with the database. These files live in WEB-INF/indices. In addition, the CDM uses the hibernate-envers auditing library to version the objects in CATE. Both hibernate-search, and hibernate-envers work using hibernate listeners that react to lifecycle events. These are configured within the hibernate configuration file, and work transparently from the perspective of the application.

The CATE service layer itself is relatively shallow, and consists of a couple of custom formatters, and a few custom services. As with the DAOs, some of the remaining services may be commited to the EDIT repository in the medium term. Transactions are managed by hibernate and spring using @Transactional annotations on services for the main part. Once objects are returned from the service layer the transaction is closed and the object is detached (in the hibernate sense, meaning that any calls to uninitialized properties will give rise to a LazyInitializationException).

The persistence layer is configured using the files in cate-persistence/src/main/resources/org/cateproject/persistence/, with the files called applicationContext*.xml being spring application context files, and the files called jbpm.* and the files in the workflows subdirectory being related to jBPM. The service layer does not require any configuration, as the services are annotated with the spring @Service stereotype.