title: loadUserByUsername function of security does not fetch the user properly through userDao.findByUsername(username) function
body: <p>The loadUserByUsername function of security service class receives username properly, However when the username is used to fetch the user from user table through findByUsername(username) function of user Dao interface it is not fetching the proper use, instead returns a random value such as "User@27387662".</p>
  
  <p>j
  Hibernate: select user0_.id as id1_1_, user0_.email as email2_1_, user0_.enabled as enabled3_1_, user0_.password as password4_1_, user0_.username as username5_1_ from user user0_ where user0_.username=?
  Hibernate: select userroles0_.user_id as user_id3_2_0_, userroles0_.user_role_id as user_rol1_2_0_, userroles0_.user_role_id as user_rol1_2_1_, userroles0_.role_role_id as role_rol2_2_1_, userroles0_.user_id as user_id3_2_1_, role1_.role_id as role_id1_0_2_, role1_.name as name2_0_2_ from user_role userroles0_ left outer join role role1_ on userroles0_.role_role_id=role1_.role_id where userroles0_.user_id=?
  com.invoice.domain.User@27387662</p>
  
  <p>j is the username and</p>
  
  <p>com.invoice.domain.User@27387662 is returned by findByUsername(username) function,</p>
  
  <p>Where would the issue be? </p>
  
  <p>Within the function to check whether the username is received a println function is used and that prints the name as well as the user returned by the findByUsername(username) is also printed.</p>
  
  <pre><code>User Security Service:
  ____________________
  
  
  package com.invoice.service.impl;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.security.core.userdetails.UserDetails;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.core.userdetails.UsernameNotFoundException;
  import org.springframework.stereotype.Service;
  
  import com.invoice.dao.UserDao;
  import com.invoice.domain.User;
  
  
  @Service
  public class UserSecurityService implements UserDetailsService {
  
      /** The application logger */
   private static final Logger LOG = LoggerFactory.getLogger(UserSecurityService.class);
  
   @Autowired
      private UserDao userDao;
  
      @Override
   public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
       System.out.println(username);
      User user = userDao.findByUsername(username);
      System.out.println(user);
      if (null == user) {
          LOG.warn("Username {} not found", username);
          throw new UsernameNotFoundException("Username " + username + " not found");
      }
      System.out.println(user);
      return user;
   }
  }
  
  
  UserDao
  _______
  
  package com.invoice.dao;
  
  import org.springframework.data.repository.CrudRepository;
  
  import com.invoice.domain.User;
  
  public interface UserDao extends CrudRepository&lt;User, Long&gt; {
  User findByUsername(String username);
      User findByEmail(String email);
  
  }
  </code></pre>