[hibernate-dev] DTO Projection support for native queries?

2017-08-18 Thread Arnold Gálovics
Hi all,

I'm particularly interested in the usecase when you want to have a DTO
projection from a native query. Currently as far as I know this is not
supported through the JPA API.

If I say entityManager.createNativeQuery("...", SomeDTO.class) Hibernate
says SomeDTO is not an entity, at least that's what I remember.

Now I implemented the support for the Tuple type for native queries, so
implementing the support for DTO projections shouldn't be an issue.

Is there any reason why this is not supported yet?

Thanks in advance!

Best,
Arnold
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] DTO Projection support for native queries?

2017-08-18 Thread Steve Ebersole
That error might be the manifestation of the problem, but its just a
symptom of the fact that this is not supported.  The type passed in to type
the query must match what is selected (your "...").

And in fact JPA and Hibernate *do* support this, just not the way you do
it.  You have to use a ResultSet mapping (see
@javax.persistence.SqlResultSetMapping).  You'd specify
a javax.persistence.ConstructorResult.

Hibernate has an alternative means to support this using
a org.hibernate.transform.ResultTransformer

On Fri, Aug 18, 2017 at 9:47 AM Arnold Gálovics 
wrote:

> Hi all,
>
> I'm particularly interested in the usecase when you want to have a DTO
> projection from a native query. Currently as far as I know this is not
> supported through the JPA API.
>
> If I say entityManager.createNativeQuery("...", SomeDTO.class) Hibernate
> says SomeDTO is not an entity, at least that's what I remember.
>
> Now I implemented the support for the Tuple type for native queries, so
> implementing the support for DTO projections shouldn't be an issue.
>
> Is there any reason why this is not supported yet?
>
> Thanks in advance!
>
> Best,
> Arnold
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Re: [hibernate-dev] DTO Projection support for native queries?

2017-08-18 Thread Arnold Gálovics
Hey Steve,

Thanks for the answer.

I was aware of these two solutions but there are definitely projects which
want to use DTO projections and cannot (don't) want to utilize neither the
annotation nor the native Hibernate API.

I think using the approach I mentioned would be beneficial, at least I see
the potential.

Do you think if we implement this it would violate some contract or do you
see anything which prevents us from supporting this?

Thanks.

Best,
Arnold

On 18 Aug 2017 17:16, "Steve Ebersole"  wrote:

That error might be the manifestation of the problem, but its just a
symptom of the fact that this is not supported.  The type passed in to type
the query must match what is selected (your "...").

And in fact JPA and Hibernate *do* support this, just not the way you do
it.  You have to use a ResultSet mapping (see
@javax.persistence.SqlResultSetMapping).
You'd specify a javax.persistence.ConstructorResult.

Hibernate has an alternative means to support this using
a org.hibernate.transform.ResultTransformer

On Fri, Aug 18, 2017 at 9:47 AM Arnold Gálovics 
wrote:

> Hi all,
>
> I'm particularly interested in the usecase when you want to have a DTO
> projection from a native query. Currently as far as I know this is not
> supported through the JPA API.
>
> If I say entityManager.createNativeQuery("...", SomeDTO.class) Hibernate
> says SomeDTO is not an entity, at least that's what I remember.
>
> Now I implemented the support for the Tuple type for native queries, so
> implementing the support for DTO projections shouldn't be an issue.
>
> Is there any reason why this is not supported yet?
>
> Thanks in advance!
>
> Best,
> Arnold
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Re: [hibernate-dev] DTO Projection support for native queries?

2017-08-18 Thread Steve Ebersole
On Fri, Aug 18, 2017 at 10:21 AM Arnold Gálovics 
wrote:

> Hey Steve,
>
> Thanks for the answer.
>
> I was aware of these two solutions but there are definitely projects which
> want to use DTO projections and cannot (don't) want to utilize neither the
> annotation nor the native Hibernate API.
>
> I think using the approach I mentioned would be beneficial, at least I see
> the potential.
>
> Do you think if we implement this it would violate some contract or do you
> see anything which prevents us from supporting this?
>

It's not a question of whether we *can* do this.  Its programming...
essentially anything is possible.  Its a question of whether it makes
sense.  And I personally am not sure this does conceptually, although I
will for sure listen to other opinions.

At the very least however I am not even going to consider this in 5.x

And btw... you say you do not want to use the native Hibernate APIs yet you
want to use some Hibernate-specific feature beyond the spec.  Assuming the
desire to not use the Hibernate APIs is to allow for that completely
pie-in-the-sky idea of provider portability adding this feature actually
introduces a unequivocally worse situation.  At least when you use the
Hibernate-specific APIs you will get a compile-time error when you switch
vendors; but using this proposed feature you'd only get such a error at
runtime - and you'd still have the problem of how to solve this in the new
provider...
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

[hibernate-dev] Hibernate ORM 5.1.10.Final Released

2017-08-18 Thread Gail Badner
http://in.relation.to/2017/08/18/hibernate-orm-5110-final-release/
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev