Hibernate 4.3.1 - 多表上的本机查询只返回一条记录

时间:2017-11-06 08:53:22

标签: oracle hibernate nativequery hibernate-native-query

我正在使用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....
}

0 个答案:

没有答案