Eduardo Simioni (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-13170 (
https://hibernate.atlassian.net/browse/HHH-13170?atlOrigin=eyJpIjoiMzhhMz...
)
Re: GORM: Challenges migrating away from deprecated Criteria API (
https://hibernate.atlassian.net/browse/HHH-13170?atlOrigin=eyJpIjoiMzhhMz...
)
Some examples:
1)
criteria.add(Restrictions.sqlRestriction( " ? between starts_on and IFNULL(ends_on,
current_date)" , getTodayNoTime(), CalendarType.INSTANCE));
2)
criteria.add(Restrictions.sqlRestriction( "CAST(TIMESTAMPADD(SQL_TSI_DAY,
-({alias}.days_before_send), {alias}.next_on) as DATE) <= ?" , getTodayNoTime(),
CalendarDateType.INSTANCE));
3)
criteria.add(Restrictions.sqlRestriction( "this_.id not in(select cgc.customer_id
from customer_group cg inner join customer_group_customer cgc on(cg.id =
gc.customer_group_id) where cg.account_id = this_.account_id)" ));
4)
Criteria criteria = createEntityCriteriaBypassAccount();
criteria.add(Restrictions.sqlRestriction( "this_.id NOT IN (SELECT
daa.digital_account_id FROM digital_account_attribute daa WHERE daa.name " +
"= ?) AND this_.id IN (SELECT DISTINCT p.payee_id FROM payment p WHERE
p.release_date > ? AND p.type IN( 'CREDIT_CARD' , " +
" 'INSTALLMENT_CREDIT_CARD' ))" , new Object
[]{DigitalAccountAttributeName.HAS_CREDIT_CARD_PAYMENT.name(), getCalendar()},
new Type[]{StringType.INSTANCE, CalendarType.INSTANCE}));
return criteria.list();
5)
criteria.add(Restrictions.sqlRestriction( "this_.id in(select max(pns.id) from
payment_notification_status pns where pns.payment_id = ?)" , paymentId,
LongType.INSTANCE));
6)
Calendar last24Hours = CalendarUtils.addDays(getCalendar(), -1);
Criteria criteria = createEntityCriteriaBypassAccount();
criteria.add(Restrictions.gt( "createdOn" , last24Hours));
Type[] types = {IntegerType.INSTANCE, IntegerType.INSTANCE, CalendarType.INSTANCE};
Object [] values = {ResponseStatus.OK,
PaymentNotificationStatus.MAX_NOTIFICATION_ATTEMPTS, last24Hours};
String subQuery1 = "this_.payment_id NOT IN (SELECT pns.payment_id FROM
payment_notification_status pns "
+ "WHERE (pns.status_code = ? OR pns.attempt_number=?) AND pns.created_on >
?)" ;
criteria.add(Restrictions.sqlRestriction(subQuery1, values, types));
String subQuery2 = "this_.id IN (SELECT max(pns2.id) FROM payment_notification_status
pns2 "
+ "WHERE pns2.status_code <> ? AND pns2.attempt_number < ? AND
pns2.created_on > ? GROUP BY pns2.payment_id)" ;
criteria.add(Restrictions.sqlRestriction(subQuery2, values, types));
7)
Type[] types = {CalendarType.INSTANCE, CalendarType.INSTANCE, StringType.INSTANCE,
CalendarType.INSTANCE, CalendarType.INSTANCE};
Calendar start = sanitizeStartDate(filter);
Calendar end = sanitizeEndDate(filter);
Object [] values = {start, end, PaymentStatus.CONFIRMED.name(), start, end};
String subQuery = "select max(payment_.id) from payment payment_ inner join charge
charge1_ on payment_.charge_id=charge1_.id where payment_.type in ('"
+ PaymentType.CREDIT_CARD + " ', ' " +
PaymentType.INSTALLMENT_CREDIT_CARD
+ "') and ((payment_.date >= ? and payment_.date < ? and payment_.status
= ? and payment_.partial_refund = 0"
+ ") or (payment_.updated_on >= ? and payment_.updated_on < ? and
payment_.status in( '" + PaymentStatus.CUSTOMER_PAID_BACK + "' ,
'"
+ PaymentStatus.BANK_PAID_BACK + "'))) group by charge1_.charge_group_id"
;
criteria.add(sqlRestriction( "this_.id in (" + subQuery + ")" ,
values, types));
(
https://hibernate.atlassian.net/browse/HHH-13170#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-13170#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100204- sha1:f005d5a )