Page tree
Skip to end of metadata
Go to start of metadata

Overview

Documents the persistence framework.

Details

Persistence is handled by the JPA framework with a default Hibernate implementation.

The refset/translation tool includes a JPA-enabled implementation of the Domain Model objects that use annotations to define the connections, cascading, and other relationships between the various objects.  For persistence interdependence, we have defined three categories of objects

  • Terminology 
  • Application
  • Workflow

Terminology objects represent data elements from the RF2 world (e.g. Concept, Description, Relationship, etc).  Application objects represent those things that exist within the scope of this tool (e.g. Refset, Translation,  ReleaseInfo, ReleaseArtifact, etc).  Worfklow objects represent states along the trajectory of editing and reference objects from the Application and Terminology worlds (mostly TrackingRecord).

Some principles:

  • Eager fetching is rarely used
  • Cascading is also rarely used, only for when objects are very tightly bound (like Translations and DescriptionTypes).
  • Objects are generally doubly-linked (e.g. Refset accesses ConceptRefsetMembers which each know their Refset).
  • The mapped superclass join strategy is always used - there are no cases of multiple object types within the same table.

Configuration

The JPA configuration is in the standard config.properties file. 

Property
Default Value
 
hibernate.dialectorg.hibernate.dialect.MySQLDialectThe default is MySQL though simply changing this should support other hibernate-supported environments.
javax.persistence.jdbc.drivercom.mysql.jdbc.DriverJDBC driver, this requires the MySQL connector to be in the classpath
javax.persistence.jdbc.urljdbc:mysql://127.0.0.1:3306/refsetDefault connection URL to a "refset" database
javax.persistence.jdbc.usern/aMySQL user
javax.persistence.jdbc.passwordn/aMySQL user's password
hibernate.show_sqlfalseUseful debug setting, change to "true" to see all queries executed by JPA layer.
hibernate.format_sqltrueFormats SQL when showing queries
hibernate.use_sql_commentstrueAdd comments when showing SQL to explain what is happening.
hibernate.jdbc.batch_size500Batch size for bulk operations.
hibernate.jdbc.default_batch_fetch_size500Batch size for fetch operations.

 

Annotations Used

Annotation
Explanation
@ColumnDefine columns, column names, and specifications about size and nullability.
@ElementCollection, @CollectionTableUsed to define collections of non JPA objects (like a set of String).
@EntityUsed to define JPA-tracked objects.
@EnumeratedUsed to indicate fields that have enumerated values.
@id @GeneratedValueUsed to managed identifier fields and ID strategy.
@ManyToOne, @OneToOne, @OneToManyUsed to define object relationships between different @Entity annotated classes.
@MappedSuperclassUsed for abstract superclasses to indicate their fields should be included in persistence of concrete subclasses.
@OrderColumnUsed to enforce list order for tracking record authors/reviewers
@TableUsed to indicate table names for objects. Default underscore-based naming convention is used.
@TemporalUsed for date fields.
@TransientUsed to avoid persistence of fields, these are typically used for DTO fields as we reuse the objects for data transfer.
@UniqueConstraintUsed to index columns that would otherwise not have indexes. Not actually used for uniqueness.

 

  • No labels