Tool Hibernate and Database Considerations

Skip to end of metadata
Go to start of metadata

Table Unique Ids

Each table should have a unique id. Hibernate does not support multi-part keys, so even if the "true" key is a combination of fields then you will still need a single unique id.

In general, the id columns should be defined as:

lesson_id BIGINT(20) NOT NULL auto_increment

The matching definition in hibernate for this field is:

 *  generator-class="native" type="java.lang.Long"
 *                column="lesson_id"
public Long getLessonId() {
     return this.lessonId;

which becomes

<id name="lessonId" type="java.lang.Long" column="lesson_id">
    <generator class="native" />

This does not apply to "reference", "lookup" or "code" tables. That is, tables that contain only a few values, do not change very often and the values are just for defining a code and its meaning. e.g. lams_grouping_type, lams_role.

Generate .hbm.xml Files Using XDoclet

Hibernate .hbm.xml files can be generated using Xdoclet. Generating, rather than hand coding, is the preferred method.

Naming Your Tool Tables

The tool's tables in the database should be named tl_< tool_signature>_<rest of name>. For example, a survey tool table is tl_lasurv10_survey_content.

Please keep all your database table names to 30 characters or less to allow migration to another database if required in the future. MySQL allows table names of up to 64 characters, so you will need to check your tablename lengths manually.

For the same reason, use the standard alphanumeric characters and "_" (underscore).

Note: These are the table name lengths we believe are supported by various databases. In the future, we will switch to longer database names if all the major databases support the longer names. These figures were gleaned from various articles on the web (mostly, so please update them if you find a more accurate reference.

Database Table name length
MySQL 64
Postgres Unknown
IBM DB 8.1/8.2 128
Oracle 91 30
SQLServer 2000 128
Sybase ASE 12.5 30
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.