I suppose it is not standard way of doing that so any tips will be helpful, here is my code:
@RequestMapping("/register")
public String register(Map<String, Object> map, @ModelAttribute("user") MyUser user) {
if(user.getLogin() == ""){
map.put("user", new MyUser());
}
else{
map.put("user", user);
map.put("result", userService.addMyUser(user));
}
return "register";
}
what cause following error:
org.hibernate.AssertionFailure: null id in org.mypackage.MyUser entry (don't flush the Session after an exception occurs)
Here is MyUser
class:
@Entity
@Table(name="MyUser")
public class MyUser{
@Id
@Column(name="idMyUser")
@GeneratedValue
private Integer id;
@Column(name="login")
private String login;
@Column(name="password")
private String password;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.