已有解决方案 - how to store fk instead the whole entity on many-to-one unidirectional:
@JoinColumn(name = "message_key")
@ManyToOne(targetEntity = Messages.class, fetch = FetchType.LAZY)
private Messages message;
@Column(name = "message_key", insertable = false, updatable = false)
private Long message_fk;
两个问题:
List<Message> messages
,并且只想保留List<Long> message_fks
。 message
个对象,它会确保一致吗?我只想使用message_fk
字段。