Re: [问题] 不同框架实作同一个JSR差异

楼主: phstudy (study)   2014-07-31 00:43:01
※ 引述《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
作者: cyclone350 (老子我最神)   2014-07-31 09:35:00
了解了,当初没想到要去看spec,感谢解惑 !

Links booklink

Contact Us: admin [ a t ] ucptt.com