@Override public Customer findCustomerById(long customerId) { Customer customer = customerRepository.findOne(customerId); if (null == customer) throw new CustomerNotFoundException(customerId); Hibernate.initialize(customer.getUser()); return customer; }
@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; }