문제

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