[hibernate-dev] dynamic instantiation queries

Steve Ebersole steve at hibernate.org
Mon Oct 24 15:19:43 EDT 2016


Historically (well before JPA) HIbernate would handle dynamic instantiation
queries in cases where one of the arguments being an entity-reference by
passing just the entity's identifier rather than a complete reference to
the entity.  To be clear, I am talking about a query like:

    select new DTO( p ) from Person p

Hibernate implicitly treats this like:

    select new DTO( p.id ) from Person p

and expects DTO to have a ctor taking the appropriate ID type.

JPA came along and also defines support for dynamic instantiation queries,
but does not specify one way or the other how this case should be handled.
I have been told other providers interpret this the opposite way.  Makes
sense.  I think it is time we at least allow that as an option.  Or maybe a
nicer implementation that looks for both and picks the available one (if
that's not too much effort).

What do y'all think?


More information about the hibernate-dev mailing list