[hibernate-dev] Fwd: Re: Proxies and typing

Steve Ebersole steve at hibernate.org
Tue Mar 20 21:19:02 EDT 2012


Forwarding a part of this discussion that got inadvertently limited to 
just Sanne and myself.

Bringing this back up because this is most likely not going to be 
accepted into JPA 2.1.  Anyway, I am all for going down the path that:

public interface User {
...
}

@Entity
@Proxy(proxyClass=User.class)
public class UserImpl implements User {
     ...
}


means that users would use User.class in all phases of the API:
User user = session.byId( User.class ).get( 1 );
EntityType<User> jpaEntityType = emf.getMetamodel().entity(User.class );
etc.

I think that is the cleanest path that allows generic-typed api.


-------- Original Message --------
Subject: Re: [hibernate-dev] Proxies and typing
Date: Thu, 26 Jan 2012 14:37:22 +0000
From: Sanne Grinovero <sanne at hibernate.org>
To: Steve Ebersole <steve at hibernate.org>

On 26 January 2012 14:02, Steve Ebersole <steve at hibernate.org> wrote:
> These emails are just between you and me.  Not sure if thats what you
> intended.  I erroneously replied to just you at one point but then sent to
> whole list also.  Anyway, just mentioning...

Ah, sorry, didn't notice either. Well last reply then, will try resume
the public conversation if I have more comments.

> The idea of requiring the interface is appealing in a way.  But, for
> example, there are odd inconsistencies then.  For example
>
> User user = session.byId( User.class ).get( 1 );
>
> but then
>
> EntityType<UserImpl> jpaEntityType = emf.getMetamodel().entity(
> UserImpl.class )
>
>
> Which I guess is my biggest hang up.  On one side we are saying that the
> impl is the entity and on the other saying the interface is the entity.
>
> You know me and consistency :)

I agree on consistency, but this is tricky, I'm not sure if you need
the UserImpl at all, maybe you can remove it from the MetaModel (maybe
after having read out other metadata from it).

Isn't such a mapping definition like a dirty workaround to actually
map the interface ?

Sanne



More information about the hibernate-dev mailing list