GoCD uses a relational database for datastore. ORM layer helps in mapping the java domain objects to the corresponding database tables and columns.
Hibernate and IBatis are used for the O/R mapping. Spring orm framework(v3.1.3) integrates Hibernate(v3.3.2) and IBatis(v220.127.116.116) to the rest of the GoCD application. The Data access layer defines DAOs which extend the corresponding DaoSupport classes exposed by Spring. These are responsible for interacting with spring to get hold of session object to query/persist the domain entities.
GoCD development started with using IBatis. Since then, we have moved some of the mappings to hibernate which makes the mapping and data-access much easier. While we hope to be able to use only one tech-stack for the ORM layer someday, we haven't seen enough benefits of one over the other yet to complete this herculean task.
applicationContext-dataLocalAccess.xml defines database related beans and contains ORM tool settings.
applicationContext-dataLocalAccess.xml defines session-factory and transaction-manager for Hibernate.
'hibernateProperties' are defined in
Hibernate mapping files are located under
As data is extensively cached , load strategy is set to be non-lazy for all entities.
Apart from the first level cache which is enabled by default, Second level cache with
read-write concurrency has been enabled for a few entities, such as User, NotificationFilter, and EnvironmentVariableConfig.
eg: in Entity.hbm.xml
We also use query cache while querying these entities. Invalidation of first and second level cache is taken care of by hibernate. We have stuck to custom caching for most of the other entities as we began to notice performance deterioration because of the way second level cache in Hibernate works. Such cached entries need to be invalidated explicitly.
Ibatis mapping files are located under
server/src/com/thoughtworks/go/server/dao/maps/. An entry needs to be made into
server/webapp/WEB-INF/sql-map-config.xml when a new mapping-xml file is added.
<sqlMap resource="com/thoughtworks/go/server/dao/maps/<New Entity>.xml"/>
Query results are explicitly cached for large and frequent queries. Cache invalidation is also handled explicitly within code.