Required software tools

  1. Eclipse 3.2 (at least)
  2. Eclipse Web Tools
  3. Apache Jakarta Tomcat Sevlet Container

Persistence

Creation of Java EE 5 entity classes from database schema

  1. Create new webapplication with Java source code compatibility version 1.5 (required for Java EE 5 persistence (annotations,...))
  2. Create new database connection to the database where the speech DB schema is already stored
  3. Call New Files Wizard -> Persistence-> Entity classes from database schema
  4. Select the database connection - the database tables should appear in the wizard
  5. Choose required tables
  6. Input package name: ipsk.db.speech
  7. Create persistence unit (Oracle/toplink) with arbitrary name
  8. Class Files and persistence.xml file should be automatically generated
  9. Copy generated class files into Eclipse project
  10. Copy persistence.xml to WEB-INF/classes/META-INF/ in Eclipse project
  11. Build and run project
  12. You might get the following error messages of the persistence manager:
    Multiple writable mappings exist for the field [yourtable.yourid]. Only one may be defined as writable, all others must be specified read-only. This is caused by possible write access to classes which have foreign key references to it.
    Problem can be solved by adding attributes "insertable=false, updatable=false" to @JoinColumn respectively @Column annotations in the referencing class. See also: A Java Programmer's Blog

Change of persistence unit classes to database schema

The persistence classes have some special modifications now, so we cannot regenerate them from the database schema. Instead the datbase schema is automatically updated on deployment with Hibernate. If the property hibernate.hbm2ddl.auto is set to update in WEB-INF/classes/META-INF/persistence.xml the schema is updated on deployment.

UUIDs for independent clients

JPA HowTo