我创建了这两个实体来证明我的问题:
OwnerEntity.java:
@Entity
public class OwnerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Size(min = 1)
@OneToMany(mappedBy = "ownerEntity", cascade = CascadeType.ALL)
private Set<ChildEntity> childEntities = new HashSet<>();
}
Run Code Online (Sandbox Code Playgroud)
ChildEntity.java:
@Entity
public class ChildEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
@NotNull
@ManyToOne(optional = false)
private OwnerEntity ownerEntity;
public ChildEntity() {
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} …Run Code Online (Sandbox Code Playgroud) 我已经阅读过ORACLE中带有视图的DML操作规则.他们中的大多数似乎对我很清楚,但我对聚合功能感到困惑.
例如,我有两个表.
EMPLOYEES
??????????????????????????????????????
? emp_id ? salary ? dept_id ?
??????????????????????????????????????
? 2134 ? 2200 ? 10 ?
? 2327 ? 3100 ? 10 ?
? 2428 ? 4100 ? 20 ?
? 2637 ? 1700 ? 30 ?
??????????????????????????????????????
\ | /
\|/
|
| DEPARTMENTS
??????????????????????????????????????
? dept_id ? dname ? location ?
??????????????????????????????????????
? 10 ? ? ?
? 20 ? ? ?
? 30 ? ? ?
??????????????????????????????????????
Run Code Online (Sandbox Code Playgroud)
我想要一个按部门显示员工平均工资的视图.所以,我运行这个SQL:
CREATE OR REPLACE VIEW dept_sals AS …Run Code Online (Sandbox Code Playgroud)