Monday, June 7, 2010

HibernateException "The class has no identifier property"

I got the above error when updating an existing record loaded from the database and not when inserting new records.

The hbm.xml file showed the following:


        <id column="user_id" type="java.lang.Long">
            <generator class="foreign">
                <param name="property">user</param>
            </generator>
        </id>

I added the name attribute in the id element, and that resolved the issue:


        <id name="id" column="user_id" type="java.lang.Long">
            <generator class="foreign">
                <param name="property">user</param>
            </generator>
        </id>

1 comment: