Unique constraint not created in JPA

后端 未结 5 1466
抹茶落季
抹茶落季 2021-01-18 01:49

I have created the following entity bean, and specified two columns as being unique. Now my problem is that the table is created without the unique constraint, and no errors

5条回答
  •  伪装坚强ぢ
    2021-01-18 02:29

    Well, I found another way to make the design. More because the design evolved than a work around.
    I heard however from a colleague, that had had the same problem, that unique constraint only are created by hibernate (we are running JBoss 4.3) when the entire database is created. It will not work when you create a new table in an existing database.
    So in persistence.xml it is necessary to set hibernate.hbm2ddl.auto to create-drop to make it work. I can not confirm this though.

提交回复
热议问题