JPA association without foreign key

后端 未结 3 635
孤城傲影
孤城傲影 2020-12-28 11:43

Is it possible to set up a ManyToOne association without JPA creating a foreign key in the database?

The tables are owned by another system and are populated asynchr

3条回答
  •  温柔的废话
    2020-12-28 11:59

    The fact that ConstraintMode.NO_CONSTRAINT is ignored looks like a bug in Hibernate 4 due to be fixed in 5.

    https://hibernate.atlassian.net/browse/HHH-8805

    The comments on that and indeed this post here:

    Multiple relationships with single mapping table without generating foreign keys by Hibernate

    suggest adding the deprecated (hibernate rather than JPA) annotation

    @ForeignKey( name = "none" )
    

    to the relationship should work.

提交回复
热议问题