如何配置基于休眠注释的关系?
How to i configure hibernate annotation based relationship?
我有一个 table,名字是 "Pstn",还有一个用户 table。用户不必使用 Pstn table。但是有些用户可以使用它。因此,如果 pstn 有一个用户,我们想看看是谁。我如何配置休眠注释?
pstnBbkTable.setVisibleColumns(new Object[]{"pstn", "bbk", "user.firstName", "inReserve", "creationDate", "expireDate", "button"});
java.lang.IllegalArgumentException: ID 必须存在于 Container 中或作为生成的列,缺少 id: user.firstName
在 com.vaadin.ui.Table.setVisibleColumns(Table.java:691)
用户table:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_Id")
private long userId;
@Column(name = "username", nullable = false)
private String username;
@Column(name = "password", nullable = false)
private String password;
@Column(name = "first_name", nullable = false)
private String firstName;
@Column(name = "last_name", nullable = false)
private String lastName;
Pstn Table:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "pstn_Id")
private long pstnId;
@Column(name = "pstn")
private String pstn;
@Column(name = "bbk")
private String bbk;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_Id")
private User user;
********************* 更新的解决方案 ****************
我像上面那样替换了 pstn bean 字段。我认为这是因为 FetchType.EAGER-Lazy..
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_Id")
private User owner;
我像上面那样替换了 pstn bean 字段。我认为这是因为 FetchType.EAGER-Lazy..
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_Id")
private User owner;
我有一个 table,名字是 "Pstn",还有一个用户 table。用户不必使用 Pstn table。但是有些用户可以使用它。因此,如果 pstn 有一个用户,我们想看看是谁。我如何配置休眠注释?
pstnBbkTable.setVisibleColumns(new Object[]{"pstn", "bbk", "user.firstName", "inReserve", "creationDate", "expireDate", "button"});
java.lang.IllegalArgumentException: ID 必须存在于 Container 中或作为生成的列,缺少 id: user.firstName 在 com.vaadin.ui.Table.setVisibleColumns(Table.java:691)
用户table:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_Id")
private long userId;
@Column(name = "username", nullable = false)
private String username;
@Column(name = "password", nullable = false)
private String password;
@Column(name = "first_name", nullable = false)
private String firstName;
@Column(name = "last_name", nullable = false)
private String lastName;
Pstn Table:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "pstn_Id")
private long pstnId;
@Column(name = "pstn")
private String pstn;
@Column(name = "bbk")
private String bbk;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_Id")
private User user;
********************* 更新的解决方案 ****************
我像上面那样替换了 pstn bean 字段。我认为这是因为 FetchType.EAGER-Lazy..
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_Id")
private User owner;
我像上面那样替换了 pstn bean 字段。我认为这是因为 FetchType.EAGER-Lazy..
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_Id")
private User owner;