|
/**
* DB 検索
*/
public void findUsers() {
Query query;
String namePattern = null;
//Into the force されたユーザネーム means
if (!user.getUserName().equals("")) {
namePattern ='%' + user.getUserName() +'%';
}
//Look at it.
if (user.getUserCode() == ""&&user.getUserName() == "") {query = em.createQuery("from User");
}else if(user.getUserCode() != ""&&user.getUserName() == "") {
query = em.createQuery("from User where user_code = :code");
query.setParameter("code", user.getUserCode());
To
log.info(">>>ユーザコード検索");
}
else if (user.getUserCode() == ""&&user.getUserName() != "") {
To
query = em.createQuery("from User where user_name like :userName");
query.setParameter("userName", namePattern);
To
log.info(">>>ユーザ名検索");
To
}
else {
query = em.createQuery("from User where user_code = :code and user_name like :userName");
To
query.setParameter("code", user.getUserCode());
query.setParameter("userName", namePattern);
To
log.info(">>>ユーザコード・ユーザ名検索");
}
To
userList = query.getResultList();
log.info(">>>show userlist-#0", userList);
To
if (userList.isEmpty()) {
log.info(">>>ユーザリストが空");
return;
}
for(User u: userList) {
log.info(">>>show userList-#0 #1", u.getUserCode(), u.getUserName(), u.getPassword());
}
To
} |
|