Hibernate - Foreign keys instead of Entities

前端 未结 4 2104
名媛妹妹
名媛妹妹 2020-11-27 17:17

Currently, Hibernate allows me to load objects defined by *-to-one relationships directly with

entity1.getEntity2()

Is it possible to get

4条回答
  •  庸人自扰
    2020-11-27 17:18

    Yes, you can do that. You just need to make it clear for hibernate which one is the mapping that it's supposed to maintain, like so:

    @Column(name="message_key", updatable=false, insertable=false)
    private Long message_fk;
    

提交回复
热议问题