use of com.springone.myrestaurants.domain.UserAccount in project spring-data-document-examples by spring-projects.
the class UserAccountDao method merge.
@Transactional
public UserAccount merge(UserAccount userAccount) {
UserAccount merged = this.entityManager.merge(userAccount);
this.entityManager.flush();
return merged;
}
use of com.springone.myrestaurants.domain.UserAccount in project spring-data-document-examples by spring-projects.
the class UserAccountDao method findByName.
public UserAccount findByName(String name) {
if (name == null)
return null;
Query q = entityManager.createQuery("SELECT u FROM UserAccount u WHERE u.userName = :username");
q.setParameter("username", name);
java.util.List resultList = q.getResultList();
if (resultList.size() > 0) {
return (UserAccount) resultList.get(0);
}
return null;
}
use of com.springone.myrestaurants.domain.UserAccount in project spring-data-document-examples by spring-projects.
the class SignUpController method updateForm.
@RequestMapping(value = "/{username}", params = "form2", method = RequestMethod.GET)
public String updateForm(@PathVariable("username") String userName, Model model) {
UserAccount userAccount = userAccountDao.findByName(userName);
model.addAttribute("userAccount", userAccount);
addDateTimeFormatPatterns(model);
return "useraccounts/update";
}
use of com.springone.myrestaurants.domain.UserAccount in project spring-data-document-examples by spring-projects.
the class JpaUserAccountDao method findByName.
public UserAccount findByName(String name) {
if (name == null)
return null;
Query q = entityManager.createQuery("SELECT u FROM UserAccount u WHERE u.userName = :username");
q.setParameter("username", name);
java.util.List resultList = q.getResultList();
if (resultList.size() > 0) {
return (UserAccount) resultList.get(0);
}
return null;
}
use of com.springone.myrestaurants.domain.UserAccount in project spring-data-document-examples by spring-projects.
the class RestaurantController method addFavoriteRestaurant.
@RequestMapping(value = "/{id}/{userId}", params = "favorite", method = RequestMethod.PUT)
public String addFavoriteRestaurant(@PathVariable("id") String id, @PathVariable("userId") String userId, Model model) {
Restaurant restaurant = this.restaurantDao.findRestaurant(id);
//TODO will always return demo user.
UserAccount account = this.userAccountDao.findUserAccount(314L);
account.getFavorites().add(restaurant.getId());
this.userAccountDao.persist(account);
addDateTimeFormatPatterns(model);
model.addAttribute("useraccount", account);
model.addAttribute("itemId", id);
//TODO converted to return 'getUserName' instead of 'getId'
return "redirect:/useraccounts/" + account.getUserName();
}
Aggregations