我有两张桌子:
`message` (
`id` varchar(150),
`Message` varchar(1000) ,
PRIMARY KEY (`id`)
)
fallback_status (
message_key varchar(150),
fallback_delivere` tinyint(1),
fallback_read tinyint(1),
fallback_answered tinyint(1),
PRIMARY KEY (message_key)
)
我在数据库级别没有任何外键关系。我为这些表创建了两个实体
@Entity
@Table(name = "message")
public class Message {
@Id
@Column(name = "id", unique = true)
private String key;
@Column(name = "message")
String message
@OneToOne
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "message_key")
private MessageFallbackStatus messageFallbackStatus;
}
和
@Entity
@Table(name = "fallback_status")
public class MessageFallbackStatus {
@Id
@Column(name="message_key")
private String messageKey;
@Column(name="fallback_delivered")
private boolean fallbackDelivered;
@Column(name="fallback_read")
private boolean fallbackRead;
@Column(name="fallback_answered")
private boolean fallbackAnswered;
}
使用此配置,Hibernate无法在fallback_status表中保留数据。 我的问题是:
感谢您的帮助。