mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
* FIX: warnings (add generics, overrides, fix imports) - should be no effecive code change * replaced deprecated methods by default methods * FIX: more compiler warnings * FIX more warnings - no code changes * FIX: deprecated call to JsonParseException * Remove unused code, check unused variables
75 lines
2.0 KiB
Java
75 lines
2.0 KiB
Java
package org.tests.query;
|
|
|
|
import io.ebean.BaseTestCase;
|
|
import io.ebean.Ebean;
|
|
import io.ebean.Query;
|
|
import io.ebean.bean.ObjectGraphNode;
|
|
import io.ebean.bean.ObjectGraphOrigin;
|
|
import io.ebeaninternal.api.SpiQuery;
|
|
import org.tests.model.basic.Address;
|
|
import org.tests.model.basic.Customer;
|
|
import org.tests.model.basic.Order;
|
|
import org.tests.model.basic.ResetBasicData;
|
|
import org.junit.Test;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import java.util.List;
|
|
|
|
public class TestAutofetchTuneWithJoin extends BaseTestCase {
|
|
|
|
@Test
|
|
public void test() {
|
|
runQuery();
|
|
collectUsage();
|
|
}
|
|
|
|
private void runQuery() {
|
|
|
|
ResetBasicData.reset();
|
|
|
|
Query<Order> q = Ebean.find(Order.class)
|
|
.setAutoTune(true)
|
|
//.fetch("customer")
|
|
//.fetch("customer.contacts")
|
|
.where().lt("id", 3).query();
|
|
|
|
List<Order> list = q.findList();
|
|
|
|
for (Order order : list) {
|
|
order.getOrderDate();
|
|
order.getShipDate();
|
|
// order.setShipDate(new Date(System.currentTimeMillis()));
|
|
Customer customer = order.getCustomer();
|
|
customer.getName();
|
|
Address shippingAddress = customer.getShippingAddress();
|
|
if (shippingAddress != null) {
|
|
shippingAddress.getLine1();
|
|
shippingAddress.getCity();
|
|
}
|
|
// customer.getContacts()
|
|
}
|
|
|
|
SpiQuery<?> sq = (SpiQuery<?>) q;
|
|
ObjectGraphNode parentNode = sq.getParentNode();
|
|
ObjectGraphOrigin origin = parentNode.getOriginQueryPoint();
|
|
assertThat(origin).isNotNull();
|
|
// MetaAutoFetchStatistic metaAutoFetchStatistic =
|
|
// ((DefaultOrmQuery<?>)q).getMetaAutoFetchStatistic();
|
|
// if (metaAutoFetchStatistic != null) {
|
|
// List<NodeUsageStats> nodeUsageStats =
|
|
// metaAutoFetchStatistic.getNodeUsageStats();
|
|
// System.out.println(nodeUsageStats);
|
|
// List<QueryStats> queryStats = metaAutoFetchStatistic.getQueryStats();
|
|
// System.out.println(queryStats);
|
|
// }
|
|
|
|
}
|
|
|
|
private static void collectUsage() {
|
|
|
|
Ebean.getDefaultServer().getAutoTune().collectProfiling();
|
|
}
|
|
|
|
}
|