查询一个与另一个对象具有OneToOne关系的实体时遇到问题。这是方案:
数据库表:
create table people (
id decimal(10,0) NOT NULL,
email varchar(512) NOT NULL
);
create table users (
email varchar(512) NOT NULL
);
Run Code Online (Sandbox Code Playgroud)
测试数据:
insert into users (email) values ('jhon@domain.com');
insert into users (email) values ('mary@domain.com');
insert into people (id, email) values (1, 'jhon@domain.com');
insert into people (id, email) values (2, 'mary@domain.com');
Run Code Online (Sandbox Code Playgroud)
实体:
@Entity(name = "people")
public class Person implements Serializable {
@Column
@Id
private long id;
@Column
private String email;
public long getId() {
return id;
}
public …Run Code Online (Sandbox Code Playgroud)