[hibernate-dev] Covariant returns

Guillaume Smet guillaume.smet at gmail.com
Tue Mar 13 19:55:35 EDT 2012


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?

-- 
Guillaume




More information about the hibernate-dev mailing list