Persistence Layer - bptlab/chimera GitHub Wiki

The persistence layer is responsible to store the domain model objects, i.e. case models, cases, and their respective members (fragments, nodes, ...), in the database. To this end we use the EclipseLink JPA framework. EclipseLink provides functionalities to automatically store Java Objects in a database. Therefore classes have to be annotated. After that annotated classes can be automatically persisted to the database using an EntityManager object. Intern Eclipse Link creates a relation in the database for every Object of an annotated class. Primitive datatype variables are saved as relation attributes. Variables representing instances of other annotated classes are saved using relationships between relations. To be persistable every Class must have an unique primary key, which has to be annotated with @Id. In Chimera there are packages for representing data models. For example the model package contains all classes representing a CaseModel. For the purpose of persisting CaseModels every class of such packages is annotated. The annotations specify a primary key (@Id) and relations to other classes which should be persisted (@OneToOne, @OneToMany). Furthermore, to provide a primary key, every Class which should be saved has an unique dbId. This Id is created automatically be EclipseLink. For that the @GeneratedValue annotation is used. For finally persist a CaseModel every CaseModel object has as method saveCaseModel(). This method uses the DomainModelPersistenceManager (package: persistencemanager) to persist a complete CaseModel.

In addition to annotating classes you have to provide a persistence.xml containing all the information EclipseLink needs to connect to the database and create the tables. In Chimera the persistence.xml is located under "/chimera-case-engine/src/main/resources/META-INF/persistence.xml". Because parameters like the username and password of the database are different for every installation of Chimera only a persistence_template.xml is pushed to GitHub. So for using Chimera you have to set these parameters.