From 83148842ce3e677527a12ff95fdcfc702062b870 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Fri, 27 Apr 2007 03:13:10 +0000 Subject: [PATCH] Order by random. Probably this isn't very optimal. --- src/java/com/samskivert/jdbc/depot/clause/OrderBy.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/java/com/samskivert/jdbc/depot/clause/OrderBy.java b/src/java/com/samskivert/jdbc/depot/clause/OrderBy.java index c7fb4e5..f834e1e 100644 --- a/src/java/com/samskivert/jdbc/depot/clause/OrderBy.java +++ b/src/java/com/samskivert/jdbc/depot/clause/OrderBy.java @@ -25,6 +25,7 @@ import java.sql.SQLException; import com.samskivert.jdbc.depot.ConstructedQuery; import com.samskivert.jdbc.depot.expression.ColumnExp; +import com.samskivert.jdbc.depot.expression.LiteralExp; import com.samskivert.jdbc.depot.expression.SQLExpression; /** @@ -35,6 +36,14 @@ public class OrderBy extends QueryClause /** Indicates the order of the clause. */ public enum Order { ASC, DESC }; + /** + * Creates and returns a random order by clause. + */ + public static OrderBy random () + { + return ascending(new LiteralExp("rand()")); + } + /** * Creates and returns an ascending order by clause on the supplied column. */