Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 792 Bytes

README.md

File metadata and controls

39 lines (31 loc) · 792 Bytes

Description

This is sample code with spring-jpa-querydsl.

It has two types of @Query(@NamedQuery) and QueryDsl (inner join and paging).

@Query(@NamedQuery)

  // Using @Query example. (Actual using @NamedQuery in {@link com.boot.jpa.domain.User})
	@Query(value = "select new com.boot.jpa.vo.ResultVO("
				+ "u.userNo,"
				+ "u.type,"
				+ "ui.email) "
			+ "from User u inner join u.userInfo ui "
			+ "where u.type = :type"
	)

QueryDsl

	JPAQuery query = new JPAQuery(entityManager);
		
	query.from(qUser)
	     .innerJoin(qUser.userInfo, qUserInfo)
	     .where(qUser.type.eq(User.USER_TYPE.USER))
	     .list(Projections.bean(ResultVO.class, 
	     	qUser.userNo,
		qUser.type,
		qUserInfo.email
	     ));

Run

	mvn test

for test