1
尋找查詢語言以使用java對象。找到MQL(Mule查詢語言)。 它在測試版中,我沒有找到很多文檔。嘗試過幾件事情,比如where子句和select子句。但訂單條款不起作用。Mule查詢語言 - 按條款排序
List users = new ArrayList();
users.add(new User("Dan", "[email protected]",2,13000 , address));
address = new Address("International pkway","Atlatna","GA","USA");
users.add(new User("Joe", "[email protected]", 1,14000, address));
users.add(new User("John", "[email protected]", 1,16000, address));
users.add(new User("Scott", "[email protected]", 1,15000, address));
users.add(new User("Andy", "[email protected]", 1,7000, address));
Query query = new QueryBuilder()
.as("p")
.orderby("income")
// .max(3)
.where(eq(property("companyId"), 1))
.select(newObject()
.set("name", "name")
.set("income", "income")
.set("email", "email")).build();
Collection result1 = query.execute(users);
請讓我知道,如果任何人有運氣MQL播放或暗示任何其他很好的框架來查詢Java對象。
Another error – when the result set is not hashmap.
Exception in thread 「main」 java.lang.ClassCastException: com.mql.test.User cannot be cast to java.util.Map
at com.mulesoft.mql.impl.OrderByComparator.compare(OrderByComparator.java:11)
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at java.util.Collections.sort(Collections.java:159)
at com.mulesoft.mql.Query.order(Query.java:214)
at com.mulesoft.mql.Query.execute(Query.java:189)
List persons = getPersons();
Query query = new QueryBuilder()
// .where(and(eq(property(「division」), 「Sales」),
// eq(property(「firstName」), 「Joe」)))
.orderby(「income」)
.max(3)
.build();