我正在使用 Hibernate 4.3.1 通过使用具有匹配数据的列从四个不同的不相关表中获取记录。为此,我编写了一个查询,如下所示
SELECT ca.csc_issuer_id as cssIssuerId,
ca.csc_serial_number as cssSerialNumber,
ca.csc_type as cssType,
ca.csc_lifecycle_count as cssLifecycleCount,
aa.app_provider_id as ...,
aa.provider_app_serial_number as ...,
aa.card_app_serial_number as ..,
aa.app_type as ..,
pa.csc_issuer_id as ..,
pa.csc_serial_number as ..,
pa.prodType
FROM AATable AA, CATable CA, PATable PA
WHERE AA.CSC_SERIAL_NUMBER = CA.CSC_SERIAL_NUMBER
AND AA.CSC_SERIAL_NUMBER = PA.CSC_SERIAL_NUMBER
AND AA.CSC_SERIAL_NUMBER = 123456
AND AA.csc_issuer_id = 26
AND AA.csc_type = 1
AND AA.csc_lifecycle_count = 0
AND PA.app_provider_id = 26
AND PA.provider_app_serial_number = 123456
AND PA.card_app_serial_number = 0
当我直接在 Oracle 数据库上运行此查询时,它返回 3 行(所有这些显然都匹配所有 where 条件,但每一行都有不同的 PATable.prodType 列的值)但是当我在我的 java 代码中使用它时,Hibernate 只返回一行是 SQL 返回的第一行。知道发生了什么吗?我尝试过加入表格,但结果相同。
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Builder
public class MyPOJO {
private Long cssIssuerId;
private Long cssSerialNumber
other members....
}