-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate removes own criteria and some features?
PostPosted: Mon Jul 18, 2016 8:11 am 
Newbie

Joined: Thu Oct 01, 2015 5:47 am
Posts: 4
I have somehow skipped the community discussion about total deprecation in hibernate. Hibernate Criteria is deprecated as well as Hibernate's SQL query with setResultTransformer.
I migrate to native JPA as proposed in deprecation text and I feel a little bit f*cked up. No unions, no simple result transformers (I must create constructors or use Entities as result handlers), one-line-hibernate-criteria queries became 10-20 lines of native jpa queries, no sub-selects, etc.. 90% of code to make it work I should write as native sql.
Some deprecations are really cool

Quote:
* @deprecated (since 5.2)
* @todo develop a new approach to result transformers


So we already deprecate this one, and new approach will be implemented someday.
So I don't understand why it was decided to remove powerful features, that were distinctive features of hibernate?


Top
 Profile  
 
 Post subject: Re: Hibernate removes own criteria and some features?
PostPosted: Mon Jul 18, 2016 8:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
ResultTransformers are going to be replaced by some functional interfaces which can be better expressed with Lambdas. They will never be removed "per se".

As for Criteria API, although it's a little bit verbose to instantiate it, it's no way less powerful than legacy Criteria. You said that it does not support subselects, but that's not true. You can also benefit from Metamodel and write type-safe queries which are not possible with legacy Criteria.

If there is some feature that was possible with legacy Criteria and which cannot be expressed through Criteria API, we'll have to support some sort of unwrapping and extend beyond JPA. But on the long run, there is no sense in maintaining two APIs which offer the same functionality.

The legacy Criteria is not actually deprecated yet, but there is no plan on developing it either. However, if you find some legacy Criteria issue and decide to fix it, we will integrate it for you. So the development is not discontinued for good. It's just that because of lack of resources the hibernate core team must focus on other API changes. For legacy projects, there is no issue to upgrade to Hibernate 5.2 since the legacy Criteria has not gone anywhere and there is a good chance that even Hibernate 6 will still feature the legacy Criteria, so there's little to worry about.


Top
 Profile  
 
 Post subject: Re: Hibernate removes own criteria and some features?
PostPosted: Mon Jul 18, 2016 8:38 am 
Newbie

Joined: Thu Oct 01, 2015 5:47 am
Posts: 4
ResultTransformers is currently the main headache. As I see there is currently no implementation for transforming results?
Quote:
It has sub-selects

I need sub-selects in select part, not in where. Join with sub-select?
Also there is problem with grouping/ordering - hibernate transforms all aliases into col_0_...col_100.., so with JPA(at least with hibernate implementation) I cannot use some expressions and group by them, while in grouping hibernate doesn't handle aliases.
I can definitive say that migration from hibernate-native features to JPA-native is hell. I spent 2 weeks to migrate 50 daos. I can not imagine what the pain it could be if I had 1000 of daos...

P.S. Criteria is not deprecated, but Session's create criteria method is deprecated. So is there some other way to get hibernate's criteria? Over some unwrapping?

PPS: It is really funny, that jpa does not support direct sub-selects in select part, but I can write a hibernates @Formula in the mapping with sub-select and then get annotated property. The problem is that Formulas are not lazy


Last edited by yorlin on Mon Jul 18, 2016 8:46 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Hibernate removes own criteria and some features?
PostPosted: Mon Jul 18, 2016 8:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
It has not been decided how the new ResultTransformer API will look like. Meanwhile, you can still as is.

As for sub-select in select clause, I think JPA does not support such a construct yet..

I think you should open some Jira issue if you stumble on some problems related to the Criteria API implementation. From 5.2, the Session.createCriteria has been indeed deprecated, as you mentioned. Bottom line, our main goal is to make the Criteria API implementation better than what legacy Criteria used to offer. Please add the Jira tickets with some replicating test cases.


Top
 Profile  
 
 Post subject: Re: Hibernate removes own criteria and some features?
PostPosted: Mon Jul 18, 2016 8:52 am 
Newbie

Joined: Thu Oct 01, 2015 5:47 am
Posts: 4
mihalcea_vlad wrote:
It has not been decided how the new ResultTransformer API will look like. Meanwhile, you can still as is.

I think you should open some Jira issue if you stumble on some problems related to the Criteria API implementation. From 5.2, the Session.createCriteria has been indeed deprecated, as you mentioned. Bottom line, our main goal is to make the Criteria API implementation better than what legacy Criteria used to offer. Please add the Jira tickets with some replicating test cases.


The problem is that JPA standard is poor, not the problems in hibernate implementation(but some times it is hibernate's problem, as I wrote before problem with aliases in grouping clause). Hibernate features are more about native sql(what can native sql - hibernate can do), but jpa is more about abstraction, which has nothing with native sql.

In any case really thanks for the explanation about situation in hibernate.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.