Sumit Kamboj
Sumit Kamboj

Reputation: 856

Where to find out database table object in simple JPA repository

I am new to Spring Boot and trying to work with JPA repository. I am trying to find out where does spring SimpleJpaRepository class save database table at runtime to perform further retrieve operation. I have below service class to retrieve user based on username. In eclipse I am trying inspect userRepository at line 9 but I don't know where I can find the values fetched from DB table by spring. I know that User class will have the details I am trying to find out but I want to see where these details are in userRepository. Any help is much appreciated.

package com.hellokoding.auth.service;

@Service
public class UserDetailsServiceImpl implements UserDetailsService{

@Autowired
private UserRepository userRepository;

@Override
@Transactional(readOnly = true)
public UserDetails loadUserByUsername(String username) {
    User user = userRepository.findByUsername(username); //line 9
    if (user == null) throw new UsernameNotFoundException(username);

    Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
    for (Role role : user.getRoles()){
        grantedAuthorities.add(new SimpleGrantedAuthority(role.getName()));
    }

    return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), grantedAuthorities);
}
}

enter image description here

Upvotes: 2

Views: 1371

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81882

You are looking at the wrong library. Spring Data JPA is just a frontend for JPA (most likely Hibernate). In there you want to look for implementations of the EntityManager interface.

Upvotes: 1

Related Questions