Вопрос

I am trying to generate foreign keys via hibernate hbm2ddl with:

   hibernate.hbm2ddl.auto=update

And using the following mapping:

   @OneToOne
   @ForeignKey(name="FK_address_nationality_id")
   private Nationality country;

It creates the table, with a country column but no foreign key is created. Why might this be?

Это было полезно?

Решение

Make sure you are using field access type when using field definition annotations rather than properties.

@Entity
@Table
@AccessType("field")

Especially if you are sub classing a class that uses property accessors.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top