#2876 & #2875 - Query Beans subquery exists/notExists + eq(other property), ne(other property)

This commit is contained in:
Rob Bygrave
2022-11-02 16:14:44 +13:00
parent b300db77ff
commit f6b87ed0b4
4 changed files with 120 additions and 0 deletions
@@ -83,6 +83,17 @@ public abstract class PBaseValueEqual<R, T> extends TQPropertyBase<R> {
return _root;
}
/**
* Is equal to another property.
*
* @param other the other property to compare
* @return the root query bean instance
*/
public final R eq(TQProperty<?> other) {
expr().raw(_name + " = " + other.propertyName());
return _root;
}
/**
* Is equal to if value is non-null and otherwise no expression is added to the query.
* <p>
@@ -135,6 +146,17 @@ public abstract class PBaseValueEqual<R, T> extends TQPropertyBase<R> {
return _root;
}
/**
* Is not equal to another property.
*
* @param other the other property to compare
* @return the root query bean instance
*/
public final R ne(TQProperty<?> other) {
expr().raw(_name + " <> " + other.propertyName());
return _root;
}
/**
* Is in a list of values.
*
@@ -693,6 +693,22 @@ public abstract class TQRootBean<T, R> {
return root;
}
/**
* Add EXISTS sub-query predicate.
*/
public R exists(Query<?> subQuery) {
query.where().exists(subQuery);
return root;
}
/**
* Add NOT EXISTS sub-query predicate.
*/
public R notExists(Query<?> subQuery) {
query.where().notExists(subQuery);
return root;
}
/**
* Execute using "for update" clause which results in the DB locking the record.
*/