Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top