我有一个班级服务和一个班级雇员 Service.java
```
import lombok.Data;
import javax.persistence.*;
@Data
@Table(name = "services")
@Entity
public class ServiceResource {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String date;
private String longitude;
private String latitude;
@ManyToOne
@JoinColumn(name="employee_id")
private EmployeeResource employee;
}`Employee.java`
import lombok.Data;
import javax.persistence.*;
@Data
@Table(name = "employees")
@Entity
public class EmployeeResource {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String longitude;
private String latitude;
}
现在我想构建一个应用程序,用jpa完成服务和雇员之间的Map。这可能吗?怎么可能?
1条答案
按热度按时间mwngjboj1#
将此添加到employeeresource实体:
在serviceresource中,修改join列如下: