I'm creating a Java Spring Boot Web app and earlier today I dropped all contents of one of my tables called 'users'. In my app, the 'admin' (me) is able to register other users on the app so that they can login and use the app.
Everything was working fine prior to me doing a drop table users
command in MySQL Workbench. And now, when I go to register a user, rather than working properly, I get an error saying:
'Data too long for column 'password' at row 1'.
This was never an issue before and I'm not sure why it is now, but I have changed none of the code, and am not sure what code I could potentially attach in this post in order to further clarify the question.
Any help would be appreciated on either to
- Restore the table to where it was (which I don't think a rollback is possible here)
- Figure out what might've changed in the code.
Below I have the creation of the entity, but again, I changed none of this and everything was working fine. I do have encryption going on as well, but again, the only thing I did was drop the table and then have it recreated when running it as a 'Java Application', like I've always been doing.
package bcoreHW.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import bcoreHW.validation.PasswordMatch;
@Entity
@Table(name="Users")
@PasswordMatch(message="{register.repeatPassword.mismatch}")
public class SiteUser {
@Id
@Column(name="userId")
@GeneratedValue(strategy=GenerationType.AUTO)
private Long userId;
@Column(name="email", unique=true)
@Email(message="{register.email.invalid}")
@NotBlank(message="{register.email.invalid}")
private String email;
@Transient // meaning it will not be saved in DB
@Size(min=5, max=15, message="{register.password.size}")
private String plainPassword; //unencrytped
@Transient
private String repeatPassword;
@Column(name="password", length=50)
private String password;
@Column(name="role", length=20)
private String role;
public String getPlainPassword() {
return plainPassword;
}
public void setPlainPassword(String plainPassword) {
this.password = new BCryptPasswordEncoder().encode(plainPassword);
this.plainPassword = plainPassword;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRepeatPassword() {
return repeatPassword;
}
public void setRepeatPassword(String repeatPassword) {
this.repeatPassword = repeatPassword;
}
}