Spring Boot Rest应用程序-非常缓慢或失败的查询执行

时间:2019-03-07 16:30:41

标签: java mysql spring hibernate amazon

我找不到哪个错误,并且Crud存储库上的save实体非常慢,甚至失败。 控制台上的最后一条消息是“使用ASTQueryTranslatorFactory的HHH000397”

我尝试注册用户

@Data
@RequiredArgsConstructor
@Entity
@Table(name = "users")
public class User implements UserDetails, Serializable {

private static final long serialVersionUID = 1519741365708552239L;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private long id;

@Email
@NotNull
@Column(name="email")
private  String email;

@NotNull
@Column(name="password")
private  String password;

@Transient
@NotNull
private String passwordConfirm;

@NotNull
@Column(name="firstName")
private  String firstName;

@NotNull
@Column(name="lastName")
private  String lastName;

@CreationTimestamp
@Temporal(TemporalType.TIMESTAMP)
@Column(name="dateRegistered")
private Date dateRegistered;

@Column(name="enabled")
private boolean enabled;

@ManyToMany(cascade = CascadeType.ALL,fetch=FetchType.LAZY)
@JoinTable(name="users_roles",
            joinColumns= {@JoinColumn(name="userId")},
            inverseJoinColumns= {@JoinColumn(name="roleId")})
private Set<Role> roles;

有时请求成功,有时响应失败。 我尝试找到解决方案,但信息不清楚。我认为这与休眠有关。

我的数据库是mysql amazon rdbms。

在此先感谢您的帮助。

@存储库    公共接口UserRepository扩展了CrudRepository {

  User getUserByEmail(String email);

 }

服务:     @服务     公共类UserDetailsS​​erviceImpl实现      UserDetailsS​​ervice {

private UserRepository userRepo;

@Autowired
public UserDetailsServiceImpl(UserRepository userRepo) {
    this.userRepo = userRepo;
}

@Override
public UserDetails loadUserByEmail(String email) 
    throws UsernameNotFoundException {

    User user = userRepo.getUserByEmail(email);

    if(user == null) {
        throw new 
 UsernameNotFoundException("User " + email + " not 
  found");
    }

    return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(), user.isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities());
}

}

0 个答案:

没有答案