可变性(历史)
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
由于历史原因,DSL API 在构建 QueryPart 的内部表示方面混合了可变和不可变行为。在创建 条件表达式、列表达式(例如函数)时,假定不可变行为,而创建 SQL 语句则不然。换句话说,可以说以下内容
// Conditional expressions (immutable) // ----------------------------------- Condition a = BOOK.TITLE.eq("1984"); Condition b = BOOK.TITLE.eq("Animal Farm"); // The following can be said a != a.or(b); // or() does not modify a a.or(b) != a.or(b); // or() always creates new objects // Statements (mutable) // -------------------- SelectFromStep<?> s1 = select(); SelectJoinStep<?> s2 = s1.from(BOOK); SelectJoinStep<?> s3 = s1.from(AUTHOR); // The following can be said s1 == s2; // The internal object is always the same s2 == s3; // The internal object is always the same
另一方面,请注意,您可以随时从任何 QueryPart
中提取和修改 绑定值。
反馈
您对此页面有任何反馈吗? 我们很乐意听取您的意见!