Chapter 7. Deploying JPA Objects

Table of Contents

7.1. Configure Naked Objects
7.2. Configure Hibernate
7.3. Run the Schema Manager
7.4. Run the Fixture Manager

Once you have annotated your domain objects (Chapter 4, Annotating Domain Objects), re-implemented your repositories for JPA (Chapter 5, Implementing Repositories) and - if necessary - written UserTypes for any custom value types (Chapter 6, Supporting Custom Value Types), then you are ready to deploy your application. This consists of configuring both Naked Objects (telling it to use JPA Objects), and then configuring Hibernate as the underlying JPA provider (telling it where the database is). After that, you (or your DBA) is ready to install the database schema and (if necessary) to populate the database using the fixtures you'll have developed for prototyping.

7.1. Configure Naked Objects

The Naked Objects framework is configured using the nakedobjects.properties file. There are three main property settings that need specifying:

  • specify the JPA Objects persistor

    nakedobjects.persistor=org.starobjects.jpa.runtime.persistence.JpaPersistenceMechanismInstaller

    This specifies the class to acts as the "installer" (basically, a factory) for the persistence mechanism.

  • specify the JPA Objects reflector

    nakedobjects.reflector=org.starobjects.jpa.metamodel.specloader.JpaJavaReflectorInstaller

    This specifies the class to acts as the "installer" (basically, a factory) for an updated version of the reflector; the component that builds the Naked Objects metamodel. This is needed so that JPA Objects can interrogate the Naked Objects metamodel for JPA annotations when persisting domain objects.

  • disable bytecode providers

    nakedobjects.reflector.class-substitutor=org.nakedobjects.metamodel.specloader.classsubstitutor.ClassSubstitutorIdentity
    nakedobjects.persistor.object-factory=org.nakedobjects.runtime.persistence.objectfactory.ObjectFactoryBasic

    The first of these components is the bytecode provider, the second is a related component that is normally used to filter out the bytecode-generated subclasses.

  • register repositories

    The JPA repository implementations should be specified for nakedobjects.services key. For example:

    nakedobjects.services.prefix = org.starobjects.jpa.testapp
    nakedobjects.services = service.employee.EmployeeRepositoryJpa, service.claim.ClaimRepositoryJpa