@PersistenceContext(unitName = "디비이름")
private EntityManager entityManager;
String jpql = "SELECT m FROM member m WHERE ";
if(!id.isEmpty()) {
jpql += "m.memberId = :id ";
}
jpql += "ORDER BY createTimestamp DESC";
TypedQuery <Member> query = entityManager.createQuery(jpql, Member.class);
if(!id.isEmpty()) {
query.setParameter("memberId", id);
}
List<Member> members = query.getResultList();
'JAVA > JAVA__Framework-Springboot' 카테고리의 다른 글
Specification (0) | 2021.04.19 |
---|---|
springboot centos7 에 배포하기 (0) | 2021.03.24 |
setting (0) | 2020.03.06 |
Execution failed for task ':compileJava'. (0) | 2019.12.09 |
AuthorizationServerConfigurerAdapter (0) | 2019.11.01 |