Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top