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 DT
Do you mean we should allow the dynamic instantiation to resolve entities when
we pass the entity identifier?
I think I saw this request on StackOverflow once.
Did I understand the question properly?
Vlad
-Original Message-
From: "Steve Ebersole"
Sent: 10/24/2016 22:21
To: "hiber
So Person is your entity, e.g.:
@Entity
class Person {
@Id
Long id;
...
}
For a query like `select new DTO( p ) from Person p` Hibernate expects a
DTO like:
class DTO {
public DTO(Long id) {
...
}
}
in fact a DTO like:
class DTO {
public DTO(Person person) {
2016-10-20 21:27 GMT+03:00 Steve Ebersole :
>
>> A type should be able to define classes Interfaces and Abstract
>> classes that it can handle in their Java types.
>> This will enable implementing handlers for things like javax.script.*
>> objects that can have different providers, thus different c
Option 2# looks very nice indeed, I'd like that as it would be useful
to be able to create immutable DTOs directly from a query; but I'm
wondering what kind of difficulties this might pose, for example I'd
assume the DTO constructor would be able to trigger lazy loading of
any property of Person?
I'm not sure what you are getting at. This is a feature Hibernate has had
for close to 15 years. It's not a "new feature", I'm just proposing a new
behavior to be more consistent with what people generally expect.
On Mon, Oct 24, 2016, 3:30 PM Sanne Grinovero wrote:
> Option 2# looks very nice
I think attempting to dynamically infer what to do using the existing ctr
would be great
On 24 October 2016 at 21:49, Steve Ebersole wrote:
> I'm not sure what you are getting at. This is a feature Hibernate has had
> for close to 15 years. It's not a "new feature", I'm just proposing a new
> b
On 24 October 2016 at 21:49, Steve Ebersole wrote:
> I'm not sure what you are getting at. This is a feature Hibernate has had
> for close to 15 years. It's not a "new feature", I'm just proposing a new
> behavior to be more consistent with what people generally expect.
Yes I like the proposal;
Still not really understanding what you are getting at. Do you have an
example?
The entity passed into the "DTO" would be managed. If they wanted to
initialize stuff on that entity it would happen just as normal for a
managed entity. Is that what you mean?
On Mon, Oct 24, 2016, 4:34 PM Sanne G