【发布时间】:2015-06-08 06:49:53
【问题描述】:
我正在尝试使用同一类的一对一休眠关系创建“命令链”:
@Entity
public class Command {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true)
private Long id;
@ElementCollection
@LazyCollection(LazyCollectionOption.FALSE)
private List<String> commandWithArguments = new ArrayList<String>();
private ExecutionStatus status = ExecutionStatus.NOT_EXECUTED;
@OneToOne(mappedBy = "parentCommand", cascade = CascadeType.ALL)
private Command child;
@OneToOne(mappedBy = "child", cascade = CascadeType.ALL)
private Command parentCommand;
@OneToOne(mappedBy = "command")
private ExecutionResult result;
public Command() {
}
....
hibernate 支持这样的关系吗?初始化时抛出如下异常:
Initial SessionFactory creation failed.org.hibernate.AnnotationException: Unknown mappedBy in: com.dockerhosting.domain.system.Command.child, referenced property unknown: com.dockerhosting.domain.system.Command.parentCommand
您可以看到 parentCommand 属性并没有丢失。
我使用的是休眠 4.3.8
【问题讨论】:
标签: java hibernate jpa hibernate-mapping