我有2个域对象作业和 JobModified 。我想映射到单个Jpa存储库,以便在输出中我得到字段和值的正确映射。 现在,当我点击JobModified时,我只获得值,但是当我点击Job时,我得到了正确的字段值映射。有没有办法在不创建另一个存储库的情况下完成它 --------
public interface IJobRepository extends JpaRepository<Job, Long> {
@Query(nativeQuery = true, value = "SELECT DISTINCT " + " WJOB.JOB_SEQ_ID, " + " COMP.CMPNT_SEQ_ID, "
+ " WJOB.SHP_SEQ_ID, " + " WJOB.JOB_NUM," + " WJOB.JOB_DESC, " + " RPT.RPT_STTS, " + " DTLS.CUST_NM, "
+ " DTLS.RCPT_DT, " + " DTLS.SHPMNT_DT," + " DTLS.TRBN_SRL_NUM, ....... WJOB.JOB_SEQ_ID = CS.JOB_SEQ_ID")
List<Job> requestJobs();
@Query(nativeQuery = true, value = "SELECT WJOB.JOB_SEQ_ID , " + " COMP.CMPNT_SEQ_ID , " + " WJOB.SHP_SEQ_ID , "
+ " WJOB.JOB_NUM , " + " WJOB.JOB_DESC , " + " RPT.RPT_STTS, " + ..................
+ " and DTLS.lst_updt_dt = trunc(sysdate -1) ")
List<JobModified> fetchpreviousDayModifiedJobs();
}
----当我点击JobModified ------
时输出[
[
214596,
15,
2,
"0222",
null,
"WIP",
"BRITISH COLUMBIA HYDRO",
null,
null,
null,
1475179622000,
"501344153",
1475179622000,
"501344153",
"N"
]
]
答案 0 :(得分:0)
我相信没有办法让两个实体共享一个DAO存储库,因为它们被键入一个类,第二个是ID类型。此外,作业与 JobModified 之间的关系是什么?如果只是为了表明作业已经更新,那么拥有更新的时间戳呢?或者让ENUM显示某种生命周期状态。
你正在尝试做的事情违反了OOP的原则,这将是单一的责任。哪个班级知道如何做一件事并做得好。