/** * Extracted method for type-safety */ private <Z> Condition condition(Table<?> pivot, Field<Z> field) { return field.equal(pivot.field(field)); }
/** * Extracted method for type-safety */ private <Z> Condition condition(Table<?> pivot, Field<Z> field) { return field.equal(pivot.field(field)); }
/** * Get a type-safe condition */ private <T> Condition getCondition(Field<T> field, Object string) { return field.equal(field.getDataType().convert(string)); }
/** * Get a type-safe condition */ private <T> Condition getCondition(Field<T> field, String string) { return field.equal(field.getDataType().convert(string)); }
@Override public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor ) { operations.add( dsl.deleteFrom( table ) .where( identityColumn.equal( ref.identity().toString() ) ) ); } } );
@Override public final Condition equalIgnoreCase(Field<String> value) { return DSL.lower(cast(String.class)).equal(DSL.lower(value)); }
/** * Add a field condition to a query */ @SuppressWarnings("deprecation") static final <T> void addCondition(org.jooq.ConditionProvider provider, Record record, Field<T> field) { // [#2764] If primary keys are allowed to be changed, the if (updatablePrimaryKeys(settings(record))) { provider.addConditions(field.equal(record.original(field))); } else { provider.addConditions(field.equal(record.getValue(field))); } }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isTrue() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(true)); else return cast(String.class).in(TRUE_VALUES); }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isFalse() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(false)); else return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); }
@Override public PM_R withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(paymentMethodsTable) .where(DSL.field(KB_PAYMENT_METHOD_ID).equal(kbPaymentMethodId.toString())) .and(DSL.field(IS_DELETED).equal(FALSE)) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).desc()) .fetchOne(); } });
@Override public List<PM_R> withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(paymentMethodsTable) .where(DSL.field(KB_ACCOUNT_ID).equal(kbAccountId.toString())) .and(DSL.field(IS_DELETED).equal(FALSE)) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).asc()) .fetch(); } });
@Override public List<RESP_R> withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(responsesTable) .where(DSL.field(KB_PAYMENT_ID).equal(kbPaymentId.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).asc()) .fetch(); } });
@Override public RESP_R withConnection(final Connection conn) throws SQLException { return DSL.using(conn, dialect, settings) .selectFrom(responsesTable) .where(DSL.field(KB_PAYMENT_ID).equal(kbPaymentId.toString())) .and(DSL.field(TRANSACTION_TYPE).equal(TransactionType.AUTHORIZE.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .orderBy(DSL.field(recordIdFieldName).desc()) .limit(1) .fetchOne(); } });
@SuppressWarnings("unchecked") private /* non-final */ Condition equal(Field<?>[] pk, T id) { if (pk.length == 1) { return ((Field<Object>) pk[0]).equal(pk[0].getDataType().convert(id)); } // [#2573] Composite key T types are of type Record[N] else { return row(pk).equal((Record) id); } }
@Override public Void withConnection(final Connection conn) throws SQLException { DSL.using(conn, dialect, settings) .update(paymentMethodsTable) .set(DSL.field(IS_DELETED), TRUE) .set(DSL.field(UPDATED_DATE), toTimestamp(utcNow)) .where(DSL.field(KB_PAYMENT_METHOD_ID).equal(kbPaymentMethodId.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .execute(); return null; } });
@Override public Reader get( EntityReference entityReference ) { String state = dsl.select( stateColumn ) .from( table ) .where( identityColumn.equal( entityReference.identity().toString() ) ) .fetchOptional( stateColumn ) .orElseThrow( () -> new EntityNotFoundException( entityReference ) ); return new StringReader( state ); }
@Override public int deleteById(ID id) { return getDSLContext().delete(table).where(primaryKey.equal(id)).execute(); }
@Override public final <Z> P fetchOne(Field<Z> field, Z value) { R record = using(configuration) .selectFrom(table) .where(field.equal(value)) .fetchOne(); return mapper().map(record); }
@Override public /* non-final */ <Z> P fetchOne(Field<Z> field, Z value) { R record = using(configuration) .selectFrom(table) .where(field.equal(value)) .fetchOne(); return record == null ? null : mapper().map(record); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private final JoinTable onKey(ForeignKey<?, ?> key, Table<?> fk, Table<?> pk) { JoinTable result = this; TableField<?, ?>[] references = key.getFieldsArray(); TableField<?, ?>[] referenced = key.getKey().getFieldsArray(); for (int i = 0; i < references.length; i++) { Field f1 = fk.field(references[i]); Field f2 = pk.field(referenced[i]); // [#2870] TODO: If lhs or rhs are aliased tables, extract the appropriate fields from them result.and(f1.equal(f2)); } return result; }