[hibernate-dev] Covariant returns

Steve Ebersole steve at hibernate.org
Wed Mar 14 11:46:27 EDT 2012


Hi Guillaume,

Was the initial problem you just using SessionImpl directly?  Or is it a 
problem of particular JDK handling the covariant return differently?  In 
the latter case we'd need to change the code.  In the former, its a 
discussion.

As for why byId is that way, TBH being new to being able to design APIs 
with Java 5+ features I tend to try things to see how they work.

On 03/13/2012 06:55 PM, Guillaume Smet wrote:
> Hi Steve,
>
> On Tue, Mar 13, 2012 at 10:39 PM, Steve Ebersole<steve at hibernate.org>  wrote:
>> As I understood it, when accessed through the Session interface what
>> return type is defined by SessionImpl is irrelevant.  And indeed I am
>> not able to reproduce this when access those methods via Session.  My
>> IDE gives me errors if I try to cast that reference to SessionImpl
>> instead.
>
> I tested it quickly in the test case I was working on and I confirm it
> works (with the Eclipse compiler and directly with Maven and the
> Oracle JDK 1.6.30 compiler).
>
> That said, I don't understand why you return the Impl instead of the
> interface: it's not consistent with byNaturalId() and
> bySimpleNaturalId() which are just below. Is there any reason why you
> treated them differently?
>

-- 
steve at hibernate.org
http://hibernate.org



More information about the hibernate-dev mailing list