Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

(If this page is useful, it will be moved into the DSpace documentation space.)

Purpose

The purpose of this document is to provide an overview of the way that the DSpace code base interacts with a database.

The mechanisms for interacting with the database layer changed significantly in DSpace 6.x.  This document will highlight those differences.

This document will also outline additional changes that are anticipated in the development of DSpace 7.x.

DSO - DSpace Objects

A DSO is a DSpace Object (Collection, Item, Bitstream).  A DSO is saved to the database.  Bitstreams are a special type of DSO that have binary storage in addition to data in the database.

Each DSO is represented as a table in the DSpace database.  Some additional tables are present to represent relationships between DSOs.

org.dspace.core.Context - DSpace Context

The DSpace Context Object contains information about about the user/session interacting with DSpace code.

The context object can be queried to determine the current user and the current user's locale.

The context object can be set to a privileged mode that can bypass all authorization checks.

The context object contains a cache (question) of objects.

Read Only Context

The Context object can be set to a read only mode for enhanced performance when processing many database objects in a read-only fashion.

Curation Context (Curator.curationContext())

A context object built to be shared between Curation tasks.

Database Interaction (before DSpace 6.x)

All Database actions requires the presence of a Context object.  

All DSOs are constructed with a Context object.  The context object provides access to the database connections to create/retrieve/update/delete DSOs.

The context object is used to authorize access to particular actions.

Data Access Objects (introduced in DSpace 6.x)

The concept of a Data Access Object (DAO) was introduced in DSpace 6 to provide an optimization layer between the DSpace code and the DSpace database.

In DSpace 6, Hibernate was implemented as the DAO.  The DAO concept would allow for a framework other than Hibernate to be implemented in the DSpace code base.

Hibernate (introduced in DSpace 6.x)

DSpace 6 introduced hibernate (http://hibernate.org/orm/) as an object relational mapping layer between the DSpace database and the DSpace code.

Objects accessed by hibernate are registered in the hibernate.cfg.xml file.  DSO properties and relationships can be inferred from the database schema.  

Hibernate Annotations in DSpace

Additional relationships can be explicitly declared using Hibernate annotations.

The Hibernate Cache and the Context Object

Hibernate will intelligently cache objects allowing for optimized performance.  The hibernate cache is accessible from the DSpace Context object.

Some care is needed to properly utilize the hibernate cache.

Read Only Context in DSpace 6

Batch Context in DSpace 6

Hibernate Queries

In order to take advantage of the hibernate cache and other hibernate features, all queries for DSOs will be performed through the hibernate framework rather than by generating SQL explicitly.

Hibernate Criteria Queries

This allows the construction of a query in an object-oriented fashion.

Hibernate Query Language (HQL)

HQL is a SQL-like query language that references hibernate object properties rather that table column names.

Hibernate Resources

  • No labels