嗨,我有一个如下定义的命名查询,但是当我执行它时,它会返回整个对象,而不仅仅是我请求的字段。当我只想返回该对象的一列时,我是否缺少某些东西。提前致谢
@NamedQueries ({
@NamedQuery(
name="findSubmissionForSubmissionRowUniqueBankId",
query="SELECT o.submission FROM SubmissionRow o WHERE o.uniqueBankId = :uniqueBankId",
hints={@QueryHint(name=QueryHints.CACHE_USAGE, value=CacheUsage.CheckCacheThenDatabase),
@QueryHint(name=QueryHints.QUERY_RESULTS_CACHE_SIZE, value="1000"),
@QueryHint(name=QueryHints.QUERY_RESULTS_CACHE_EXPIRY, value="18000")
})
})
它为此查询执行的 sql 是
EJBQueryImpl(ReadObjectQuery(name="findSubmissionForSubmissionRowUniqueBankId" referenceClass=SubmissionRow sql="SELECT ID, ARCHIVE_BANK_ID, EXTERNAL_SOURCE_DETAILS,UNIQUE_BANK_ID, SUBMISSION_ID FROM FE_TEST.SUBMISSION_ROW WHERE (UNIQUE_BANK_ID = ?)"))
我已将加入定义为以下
@ManyToOne
@JoinColumn(name = "SUBMISSION_ID", referencedColumnName = "ID")
private Submission submission;