在我的 yaml 定义中,对象没有连接。它是空的。我没有看到问题:
人:
@Entity
@Table(name="person")
public class Person extends Model {
@Id
@Constraints.Required
@Formats.NonEmpty
public Long id;
...
生命周期事件:
@Entity
@Table(name="lifecycleevent")
public class LifeCycleEvent extends Model {
@Id
@Constraints.Required
@Formats.NonEmpty
public Integer id;
@ManyToOne
@Constraints.Required
public Person author;
初始化数据.yml
lifecycleevent:
- !!models.LifeCycleEvent
title: Lorem Away 1
text: Lorem ipsum dolor sit amet, consectetuer a ...
read: 1
creationDateTime: 2010-02-11 11:02:57
publishingDateTime: 2012-01-12 07:30:00
lastEditedDateTime: 2013-03-23 15:22:00
author: !!models.Person
id: 1
考试
LifeCycleEvent lifeCycleEvent = LifeCycleEvent.findById(1);
assertThat(lifeCycleEvent).isNotNull();
assertThat(lifeCycleEvent.id).isEqualTo(1);
assertThat(lifeCycleEvent.author).overridingErrorMessage("Author of " + lifeCycleEvent + " can not be null").isNotNull();