Java Code Examples for javax.persistence.criteria.JoinType#LEFT

The following examples show how to use javax.persistence.criteria.JoinType#LEFT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinFetchTest.java    From specification-arg-resolver with Apache License 2.0 6 votes vote down vote up
@Test
public void performsTwoFetches() {
	JoinFetch<Customer> spec1 = new JoinFetch<Customer>(new String[] { "orders" }, JoinType.LEFT);
	JoinFetch<Customer> spec2 = new JoinFetch<Customer>(new String[] { "orders2" }, JoinType.INNER);
    
	Conjunction<Customer> spec = new Conjunction<Customer>(spec1, spec2);
	
    List<Customer> customers = customerRepo.findAll(spec);
    
    assertThat(customers).isNotEmpty();
    
    for (Customer customer : customers) {
    	assertTrue(Hibernate.isInitialized(customer.getOrders()));
    	assertTrue(Hibernate.isInitialized(customer.getOrders2()));
    }
}
 
Example 2
Source File: SpecificationArgumentResolverTest.java    From specification-arg-resolver with Apache License 2.0 5 votes vote down vote up
public void testMethod_joinContainerWithRegularJoin(
        @Joins({
        	@Join(path = "join1", alias = "alias1", type = JoinType.INNER, distinct = true),
        	@Join(path = "join2", alias = "alias2", type = JoinType.LEFT, distinct = false)
        })
        @Spec(path = "path1", spec = Like.class) Specification<Object> spec) {
}
 
Example 3
Source File: SpecificationArgumentResolverTest.java    From specification-arg-resolver with Apache License 2.0 5 votes vote down vote up
public void testMethod_joinContainerWithRegularAndFetchJoins(
        @Joins(value = {
        	@Join(path = "join1", alias = "alias1", type = JoinType.INNER, distinct = true),
        	@Join(path = "join2", alias = "alias2", type = JoinType.LEFT, distinct = false)
        }, fetch = {
            	@JoinFetch(paths = { "fetch1" }),
                @JoinFetch(paths = { "fetch2" }, joinType = JoinType.INNER)
            })
        @Spec(path = "path1", spec = Like.class) Specification<Object> spec) {
}
 
Example 4
Source File: JoinFetchTest.java    From specification-arg-resolver with Apache License 2.0 5 votes vote down vote up
@Test
public void fetchesLazyCollection() {
    JoinFetch<Customer> spec = new JoinFetch<Customer>(new String[] { "orders" }, JoinType.LEFT);
    
    List<Customer> customers = customerRepo.findAll(spec);
    
    assertThat(customers).isNotEmpty();
    
    for (Customer customer : customers) {
        assertTrue(Hibernate.isInitialized(customer.getOrders()));
    }
}
 
Example 5
Source File: AnnotatedSpecInterfaceJoinsE2eTest.java    From specification-arg-resolver with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/anno-iface-joins/customersByEmptyFilterExtendingParamSpec")
@ResponseBody
public List<Customer> getCustomersByItemNameOrBadgeType(
		@Joins({
				@Join(path = "orders", alias = "o", type = JoinType.LEFT),
				@Join(path = "badges", alias = "b", type = JoinType.LEFT)
		})
		@Or({
				@Spec(path = "o.itemName", params = "order", spec = Like.class),
				@Spec(path = "b.badgeType", params = "badge", spec = Equal.class)
		}) EmptyFilter spec) {
	return customerRepo.findAll(spec);
}