#526 - findPagedList with @EmbeddedId broken - automatically adds orderby t0.null

This commit is contained in:
Robin Bygrave
2016-01-13 10:43:56 +13:00
parent 55493c5b7d
commit 0453892ebd
2 changed files with 15 additions and 1 deletions
@@ -2316,7 +2316,7 @@ public class BeanDescriptor<T> implements MetaBeanInfo, SpiBeanType<T> {
*/
public void appendOrderById(SpiQuery<T> query) {
if (idProperty != null) {
if (idProperty != null && !idProperty.isEmbedded()) {
OrderBy<T> orderBy = query.getOrderBy();
if (orderBy == null || orderBy.isEmpty()) {
query.order().asc(idProperty.getName());
@@ -3,6 +3,7 @@ package com.avaje.tests.compositekeys;
import java.util.ArrayList;
import java.util.List;
import com.avaje.ebean.PagedList;
import org.junit.Assert;
import org.junit.Test;
@@ -51,6 +52,8 @@ public class TestCKeyLazyLoad extends BaseTestCase {
Ebean.save(p2);
exerciseMaxRowsQuery_with_embeddedId();
CKeyParentId searchId = new CKeyParentId(1, "one");
CKeyParent found = Ebean.find(CKeyParent.class).where().idEq(searchId).findUnique();
@@ -79,4 +82,15 @@ public class TestCKeyLazyLoad extends BaseTestCase {
Assert.assertTrue(idInTestList.size() == 2);
}
/**
* Exercise paging/maxRows type query with EmbeddedId.
*/
private void exerciseMaxRowsQuery_with_embeddedId() {
PagedList<CKeyParent> siteUserPage = Ebean.find(CKeyParent.class).where()
.orderBy("name asc")
.findPagedList(0, 10);
siteUserPage.getList();
}
}