Cosmo 0.7 Dao Layer
The Data Access Object encapsulates access to persistent data. They are responsible for CRUD operations for persistent cosmo model objects. Because Cosmo uses Hibernate as an ORM, the DAO implementations are based on Spring's
HibernateDaoSupport class, which provides access to a Hibernate
Session . Cosmo uses Spring's declarative transaction framework which means the dao's require no transaction code. It is assumed that the transaction is controlled in another layer.
Item Fiilters
ContentDao includes an api for querying
Item s using an
ItemFitler . The
ItemFilter model provides a way to specify criteria for retrieving
Item s . Although not complete and not the most robust model, it allows for many different types of queries to be performed all using the same api.
An
ItemFilter is basically a big AND query. All the criteria set on an
ItemFilter is ANDed together to match results.
Examples:
Find all
NoteItem s that belong to a collection and match a displayName:
NoteItemFilter filter = new NoteItemFilter();
filter.setParent(parent);
filter.setDisplayName("matchme");
Set<Item> results = contentDao.findItems(filter);
Find all
NoteItem s that belong to a collection, match the displayName, and have an _EventStamp and occur in a specified data range:
NoteItemFilter filter = new NoteItemFilter();
filter.setParent(parent);
filter.setDisplayName("matchme");
EventStampFilter eventFilter = new EventStampFilter();
Period period = new Period(new DateTime("20070101T100000Z"), new DateTime("20070201T100000Z"));
eventFilter.setPeriod(period);
filter.getStampFilters().add(eventFilter);
Set<Item> results = contentDao.findItems(filter);
--
RandyLetness - 22 Aug 2007