Required software tools
- Eclipse 3.2 (at least)
- Eclipse Web Tools
- Apache Jakarta Tomcat Sevlet Container
Persistence
Creation of Java EE 5 entity classes from database schema
- Create new webapplication with Java source code compatibility version 1.5 (required for Java EE 5 persistence (annotations,...))
- Create new database connection to the database where the speech DB schema is already stored
- Call New Files Wizard -> Persistence-> Entity classes from database schema
- Select the database connection - the database tables should appear in the wizard
- Choose required tables
- Input package name: ipsk.db.speech
- Create persistence unit (Oracle/toplink) with arbitrary name
- Class Files and persistence.xml file should be automatically generated
- Copy generated class files into Eclipse project
- Copy persistence.xml to WEB-INF/classes/META-INF/ in Eclipse project
- Build and run project
- 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