Added counting max for country (#54)

Co-authored-by: Inal Arsanukaev <aiz@empayre.com>
This commit is contained in:
Inal Arsanukaev 2022-08-03 12:53:34 +03:00 committed by Inal Arsanukaev
parent 077cb043df
commit ab8a179848

View File

@ -10,6 +10,8 @@ import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import static org.jooq.impl.DSL.max;
@Component
public class DominantDaoImpl extends AbstractGenericDao implements DominantDao {
@ -19,25 +21,28 @@ public class DominantDaoImpl extends AbstractGenericDao implements DominantDao {
@Override
public Long getLastVersionId() throws DaoException {
Query query = getDslContext().select(DSL.max(DSL.field("version_id"))).from(
getDslContext().select(Tables.CALENDAR.VERSION_ID.max().as("version_id")).from(Tables.CALENDAR)
.unionAll(getDslContext().select(Tables.CATEGORY.VERSION_ID.max().as("version_id")).from(Tables.CATEGORY))
.unionAll(getDslContext().select(Tables.CURRENCY.VERSION_ID.max().as("version_id")).from(Tables.CURRENCY))
.unionAll(getDslContext().select(Tables.INSPECTOR.VERSION_ID.max().as("version_id")).from(Tables.INSPECTOR))
.unionAll(getDslContext().select(Tables.PAYMENT_INSTITUTION.VERSION_ID.max().as("version_id"))
Query query = getDslContext().select(max(DSL.field("max"))).from(
getDslContext().select(max(Tables.CALENDAR.VERSION_ID)).from(Tables.CALENDAR)
.unionAll(getDslContext().select(max(Tables.CATEGORY.VERSION_ID)).from(Tables.CATEGORY))
.unionAll(getDslContext().select(max(Tables.COUNTRY.VERSION_ID)).from(Tables.COUNTRY))
.unionAll(getDslContext().select(max(Tables.CURRENCY.VERSION_ID)).from(Tables.CURRENCY))
.unionAll(getDslContext().select(max(Tables.INSPECTOR.VERSION_ID)).from(Tables.INSPECTOR))
.unionAll(getDslContext().select(max(Tables.PAYMENT_INSTITUTION.VERSION_ID))
.from(Tables.PAYMENT_INSTITUTION))
.unionAll(getDslContext().select(Tables.PAYMENT_METHOD.VERSION_ID.max().as("version_id"))
.unionAll(getDslContext().select(max(Tables.PAYMENT_METHOD.VERSION_ID))
.from(Tables.PAYMENT_METHOD))
.unionAll(getDslContext().select(Tables.PAYOUT_METHOD.VERSION_ID.max().as("version_id"))
.unionAll(getDslContext().select(max(Tables.PAYOUT_METHOD.VERSION_ID))
.from(Tables.PAYOUT_METHOD))
.unionAll(getDslContext().select(Tables.PROVIDER.VERSION_ID.max().as("version_id")).from(Tables.PROVIDER))
.unionAll(getDslContext().select(Tables.PROXY.VERSION_ID.max().as("version_id")).from(Tables.PROXY))
.unionAll(getDslContext().select(Tables.TERMINAL.VERSION_ID.max().as("version_id")).from(Tables.TERMINAL))
.unionAll(getDslContext().select(Tables.TERM_SET_HIERARCHY.VERSION_ID.max().as("version_id"))
.unionAll(getDslContext().select(max(Tables.PROVIDER.VERSION_ID)).from(Tables.PROVIDER))
.unionAll(getDslContext().select(max(Tables.PROXY.VERSION_ID)).from(Tables.PROXY))
.unionAll(getDslContext().select(max(Tables.TERMINAL.VERSION_ID)).from(Tables.TERMINAL))
.unionAll(getDslContext().select(max(Tables.TERM_SET_HIERARCHY.VERSION_ID))
.from(Tables.TERM_SET_HIERARCHY))
.unionAll(getDslContext().select(Tables.WITHDRAWAL_PROVIDER.VERSION_ID.max().as("version_id"))
.unionAll(getDslContext().select(max(Tables.TRADE_BLOC.VERSION_ID))
.from(Tables.TRADE_BLOC))
.unionAll(getDslContext().select(max(Tables.WITHDRAWAL_PROVIDER.VERSION_ID))
.from(Tables.WITHDRAWAL_PROVIDER))
.unionAll(getDslContext().select(Tables.PAYMENT_ROUTING_RULE.VERSION_ID.max().as("version_id"))
.unionAll(getDslContext().select(max(Tables.PAYMENT_ROUTING_RULE.VERSION_ID))
.from(Tables.PAYMENT_ROUTING_RULE))
);
return fetchOne(query, Long.class);