Setting up the property mappings – MiG InfoCom MiG Calendar DBConnect Guide User Manual

Page 10

Advertising
background image

MiG InfoCom AB

HSQLDB 1.8 is a viable choice for this and it is also one of the
supported database engines, as well as free to use.

DBConnect is actually not the one that detects if more than one
version of an entity exists. The depositories (ActivityDepository
and CategoryDepository) already handles this. You can install a
resolver to handle these cases. See the JavaDoc for
ActivityDepository.setActivityResolver(..) and
CategoryDepository.setCategoryResolver(..) for
information how to install your custom resolver.

Multiple Clients
If there are more than one client reading from and writing to a
backing store there is a chance that two clients update the
same entity at the same time. DBConnect does something
called optimistic locking which detects such attempts but do not
hinder them altogether as true locking would (true locking would
require that all databases was online at all times though). See
“Listening for Concurrent Events” below for how to handle this.

Setting Up the Property Mappings

What is a Property?

Activities and Categories both implement the interface

PropertyConsumer

which means they can both be used to read

and write properties from/to. The type of the property may be any Java
object. The property is defined with the class

PropertyKey

which

is, as the name indicates, used as a key to get/set the property.
Property keys has a string name and an optional enforced value type,
such as

Integer

. They are architectured so they are extremely fast

to use for lookup of the property since referential equality (==) are
used.

Both activities and categories have standard properties such as id,
date range and name. You can also freely have your own properties
and store those in the activity through the use of

PropertyKey

objects as keys and just about anything as values. This way you can
extend the functionality of the

DefaultActivity

class without sub

classing it.

Property Mappings

To be able to load and save (persist) an entity to a database or XML
file you need to map the properties of the activity (or category) to

DBConnect Guide

Page 10 / 25

Advertising