Hibernate Missing Column ID

This article covers a problem I encountered using Hibernate 3.0 and Spring 2.5.6.

Yesterday, I spend one hour to debug the following error from the Hibernate Schema Validation:

Missing column: id in MYSCHEMA.A

The table of A, named TABLE_A, indeed did not have any column “id”. The primary key column was named differently to something like “A_ID”. So I searched all mapping files in my project for that table using the search strings “A_ID” and “TABLE_A”. I hoped to find something like

<column name="id">

All I found was the mapping file for A with the correct column identifier “A_ID”. It took me one hour to realize that I only searched for uses of the table, not the class A itself. The search for “class=’A’” resulted in the following mapping from another class B which has a reference to A:

<set name="aObjects" cascade="all">
<key column="id" />
<one-to-many class="A" />

My initial search did not find that mapping file because it doesn’t contain the strings “A_ID” or “TABLE_A”. I had to search for the class name “A”. After having found the source of the problem, the solution was to change the key column from “id” to “A_ID” because that is the correct identifier for the primary key column.


If you get a “Missing column”-error during Hibernate Schema Validation, don’t just search for the identifier of the column or the identifier of the table. Instead, search for other uses of the corresponding class.