Aliaspooryorik
ColdFusion ORM Book

Hibernate, MySQL and the 1005 ErrorCode

Today seems to be wierd error message day for me. I'm using ColdFusion ORM in my application and when adding a new persistent entity to my model which has a many-to-one association to an existing entity I was getting the error:

Exception in
Error during DDL export

(org.hibernate.JDBCException)
ErrorCode: 1005 
Message: Can't create table 'mydatabase.#sql-668_e4369' (errno: 150)
SQLState: HY000

So, I tried creating the table directly in MySQL and got the same error. The error actually happens when Hibernate tries to create the Foreign Key constraint. This turns out to be due to the primary key on the table I'm linked to being an unsigned integer (BIGINT) and the foreign key column that Hibernate generated was not unsigned. Using HeidiSQL (which I prefer to MySQL workbench), I set the column to unsigned and voila - Hibernate can now create the foreign key constraint.


1 comment

  1. Ah... I had this problem too, but I never actually looked for the bottom error...
    I seemed to be the only one on the internet who had this problem, well, not any more! :)

    Comment by Jake "Master of the Universe" Hendy – August 31, 2011

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments
 

Search

Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)

Categories

Recent Posts