コード例 #1
0
 @Override
 public Customer removeCustomer(long userId, long customerId) {
   User user = userRepository.findOne(userId);
   Customer customer = customerRepository.findOne(customerId);
   user.getCustomers().remove(customer);
   this.userRepository.save(user);
   customer.setUser(null);
   this.customerRepository.delete(customer);
   return customer;
 }
コード例 #2
0
 @Override
 public Collection<Customer> loadCustomerAccounts(long userId) {
   List<Customer> customersList = this.customerRepository.findByUserId(userId);
   ArrayList<Customer> customers = new ArrayList<Customer>();
   for (Customer c : customersList) {
     Hibernate.initialize(c);
     User user = new User(userId);
     c.setUser(user);
     customers.add(c);
   }
   return Collections.unmodifiableList(customers);
 }