Re: [問題] 不同框架實作同一個JSR差異

看板java作者 (study)時間11年前 (2014/07/31 00:43), 11年前編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《cyclone350 (老子我最神)》之銘言: : 所以實作內容不是要遵照標準規格去做嗎? : 如果同一個 JSR 再不同的framework實作會產生不同的效果,那還能稱作標準嗎? 基本上SPEC不可能訂清楚所有細節, 若SPEC裡面沒訂的,就只能看各家是怎麼實作的。 不過你遇到的問題,在JPA 2.1 SPEC裡面有 Page 153 SQL Queries Returning Managed Entities from Native Queries Page 157 Returning Unmanaged Instances 在153頁有提到: Queries may be expressed in native SQL. The result of a native SQL query may consist of entities, unmanaged instances created via constructors, scalar values, or some combination of these. 範例: https://github.com/phstudy/jpa-native-query-example 所以目前看起來問題是kodo支援SPEC中沒有定義的使用方法 因此其他家的Framework行為不一致,也是合理的 另外,JPA 2.0 Page 124上面是這麼寫的: Queries may be expressed in native SQL. The result of a native SQL query may consist of entities, scalar values, or a combination of the two. The entities returned by a query may be of different entity types. 可以發現,在2.0的Native Query只定義要支援entities, scalar values, or a combination of the two. References: JSR-338 JPA 2.1 https://www.jcp.org/aboutJava/communityprocess/final/jsr338/index.html -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.195.48.44 ※ 文章網址: http://www.ptt.cc/bbs/java/M.1406738585.A.8CB.html ※ 編輯: phstudy (123.195.48.44), 07/31/2014 01:26:05 ※ 編輯: phstudy (123.195.48.44), 07/31/2014 01:44:15

07/31 09:35, , 1F
了解了,當初沒想到要去看spec,感謝解惑 !
07/31 09:35, 1F
※ 編輯: phstudy (123.195.48.44), 08/08/2014 15:11:04
文章代碼(AID): #1JsI2PZB (java)
討論串 (同標題文章)
文章代碼(AID): #1JsI2PZB (java)