1 回答

TA貢獻1815條經驗 獲得超10個贊
連接為您提供 sql 中的行結果集合:
Parent Child
p1 c1
p1 c2
p1 c3
等等。沒有將生成的集合傳遞給構造函數的機制。
JPA 規范 4.14
constructor_expression ::=
NEW constructor_name ( constructor_item {, constructor_item}* )
constructor_item ::=
single_valued_path_expression |
scalar_expression |
aggregate_expression |
identification_variable
此外,另一個問題是您的查詢可能會返回多個父項或子項。
Parent Child Child2
p1 c111 c121
p1 c121
p1 c131 c122
p2 c211 c211
p2 c221 c212
p2 c231
我猜這是因為對于底層 JPA 提供者來說,它變得太復雜了,以至于不知道在哪里拆分它,或者使用哪些值來傳遞給子構造函數,或者可能是我不熟悉的更微妙的原因。最重要的是,它要求您提供用于解析此矩陣的代碼,如果您打算這樣做,您也可以在沒有 JPA 的情況下解析結果。
添加回答
舉報