playframework 2.0 - Ebean OrderBy CASE WHEN -


When using an EBI finder, it is possible to provide an order by statement like:

 < Code> By order when a = 'foo' then 1 when a = 'bar' then 2 or 99 99 <<< "text"> 

It is possible to do this command, we have to do just that which is to add the transient field and It is annotated with @forumula with appropriate parameters.

Then the model class should look like this: @Entity Public Class A Model {Public A (Long IID, String AA) {ID = IID; A = AA; } @ Id public long id; @ Essential public string A; @ Transision @ formula (select $ =) (when $ {ta}. A = 'fu' then 1 when a = 'time' is the end of 2 and 99) "integer index; public static finder", l & gt; Find = New Finder & lt; Long, A & gt; (Long.assa, Eccles);}

In this way we have created the Virtual Column Index and we

Here is the exemplary test method:

  @Test Public Zero Attest (Fake Application = Assistant. Helpers.start (App); A 1 = New A (1L, "bar"); A2 = New A (2L, "XYZ"); A3 = New A (3L, "FOO"); AA4 = New A (4L , "AAA"); A5 = new A (5L, "FOO"); A6 = New A (6L, "bar"); a1.save (); a2.save (); a3.save ( ); a4.save (); a5.save (); a6.save (); list & lt; a & gt; list = Ebean.find (eccles) .orderBy ("index") for findList (); (AAA: list) {System.out.println ("fa.id:" + fa.id + "fa.a:" + fa.a) ";} System.out.println (" ----- -------------------- "); List & lt; a & gt; list1 = affixed. Order By (" Index "). Search Catalog (); (A FA : List 1) {System.out.println ("fa.id:" + fa.id + "fa.a:" + fa.a) "; }}    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -