我有 3 个单选按钮 1.汽车, 2.自行车, 3.两者兼而有之。所以如果我选择 汽车 如果我选择 2,它将获取所有汽车详细信息,它只会 获取汽车详细信息,直到我能够实现,但如何 如果我选择第三个单选按钮,则获取汽车和自行车详细信息 "两者兼而有之"。在下面的示例中,我想在选择"两者">时做同样的事情 它将获取所有文档。最好的解决方案是什么?
Parent class:
@MappedSuperclass
public abstract class BaseProsecutionDocument {
private long dmsDocumentId;
private long documentVersion;
private String fileName;
…
}
Pros class:
@Entity
@Table(schema = “reference”, name = “prosecution_documents”)
public class ProsDocument extends BaseProsecutionDocument {
private Long id;
private Long prosId;
private Long ocportalSubmissionId;
…
}
Sumisiion class:
@Entity
@Immutable
@Table(schema = “reference”, name = “submission_docs”)
public class submissionDocument extends BaseProsecutionDocument {
private Long id;
private Long inventionId;
…
}
I want to know how to write the query for that..like
i have written for those 2 radio buttons:
public interface ProsecutionDocumentRepository extends JpaRepository {
@Query(value = “SELECT ppd FROM ProsDocument ppd ” +
“WHERE ppd.submissionId IN (SELECT p.id FROM submission p WHERE
UPPER(p.doc) = UPPER(:doc)) ” +
“AND ppd.documentType.documentType in (‘OFFICE’)”)
Page findSubmissionOfficeDocumentsByDoc(@Param(“doc”) String docket,
Pageable pageable);
}
还是我需要将@MappedSuperClass更改为@Entity和使用 @Inheritance(策略 = 继承类型.JOINED(
-
首先使用基本字段创建基类
@MappedSuperclass public class FooBase { @Id private Long id; private String name; }
-
将此类映射到空类上的表
@Entity @Table(name = "foo") public class Foo extends FooBase{ }
-
将嵌套的对象、集合、子资源映射到另一个类上,但同一个表"foo">
@Entity @Table(name = "foo") public class FooNested extends FooBase { @Fetch(FetchMode.SUBSELECT) @OneToMany(fetch = FetchType.EAGER) @JoinColumn(name = "foo_id", insertable = false, updatable = false) @ApiModelProperty(hidden = true) private List<Bar> barList; }
-
为每个实体创建一个存储库
-
使用一个或其他存储库来 FETCh 或不实现的表/实体