use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class EntitiesTest method testPostConstruct.
@Test
void testPostConstruct() {
Order order = metadata.create(Order.class);
assertEquals(LocalDate.now(), order.getDate());
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class OrderService method createAndSaveOrder.
Order createAndSaveOrder(String number) {
Order order = dataManager.create(Order.class);
order.setNum(number);
dataManager.save(order);
return order;
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class RelatedEntityLoadingTest method jpql_relatedEntityIsLoadedLazily.
@Test
void jpql_relatedEntityIsLoadedLazily() {
authenticator.withUser("test1", () -> {
Order order = dataManager.load(Order.class).id(orderId).one();
assertNotNull(order.getCustomer());
return null;
});
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class RelatedEntityLoadingTest method docExamples.
@Test
void docExamples() {
authenticator.withUser("test1", () -> {
// tag::data-access-checks-1[]
// order is loaded only if it satisfies JPQL policies on the Order entity
Order order = dataManager.load(Order.class).id(orderId).one();
// related customer is loaded regardless of JPQL policies on the Customer entity
assert order.getCustomer() != null;
// end::data-access-checks-1[]
return null;
});
authenticator.withUser("test2", () -> {
// tag::data-access-checks-2[]
// order is loaded only if it satisfies constraints on the Order entity
Order order = dataManager.load(Order.class).id(orderId).one();
// related customer is not null only if it satisfies predicate policies on the Customer entity
if (order.getCustomer() != null) {
/*...*/
}
// end::data-access-checks-2[]
return null;
});
authenticator.withUser("test1", () -> {
// tag::data-access-checks-3[]
// loading Order
Order order = dataManager.load(Order.class).id(orderId).one();
// related customer is loaded even if the user has no permission to read the Customer entity
assert order.getCustomer() != null;
// end::data-access-checks-3[]
return null;
});
}
use of dataaccess.ex1.entity.Order in project jmix-docs by Haulmont.
the class RelatedEntityLoadingTest method jpql_relatedEntityIsLoadedEagerly.
@Test
void jpql_relatedEntityIsLoadedEagerly() {
authenticator.withUser("test1", () -> {
Order order = dataManager.load(Order.class).id(orderId).fetchPlanProperties("customer.name").one();
assertNotNull(order.getCustomer());
return null;
});
}
Aggregations