Http Status 400 外键插入错误

Http Status 400 foreign key insert error

我在向 table 添加外键时遇到问题,有什么问题吗?请帮忙。

查看部分代码:

    <td>
        <form:select path="type">
           <form:options items="${typeList}" itemValue="id" itemLabel="name" />
        </form:select>
    </td>

实体:

@Entity
@Table(name = "myTable")
public class Type {

private int id;
private String name;

public Type() {
    name = null;
}

public Type(Type type) {
    name = type.getName();
}

@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")

@Column(name = "id")
public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

@Column(name = "name")
public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

private Set<Store> stores = new HashSet<Store>(
        0);
@OneToMany
public Set<Store> getStore(){
    return this.stores;
}
public void setStore(Set<Store> stores){
    this.stores = stores;
}

}

店内实体:

.....
private Type type;
@ManyToOne//(fetch = FetchType.LAZY)
@JoinColumn(name = "idType")
public Type getType(){
    return type;
}
public void setType(Type type){
    this.type = type;
}
....

在控制器中我只是添加类型列表,并在视图中调用这个列表.. 在控制器中:

        @RequestMapping(value = "/regStore", method = RequestMethod.GET)
public ModelAndView addStore() throws SQLException {
    ModelAndView modelAndView = new ModelAndView("Store/regStore", "command", new Store());

    Store storeForm = new Store();
    modelAndView.addObject("storeForm", storeForm);

    modelAndView.addObject("typeList", typeService.getAllTypes());

    return modelAndView;
}

//post method create store
@RequestMapping(value = "/regStoreSuccessful", method = RequestMethod.POST)
public ModelAndView addStorePost(@ModelAttribute("storeForm") Store store, BindingResult bindingResult, Principal principal) throws SQLException {
    ModelAndView modelAndView = new ModelAndView("redirect:body");

    User user;
    user = userService.getUserByEmail(principal.getName());

    store.setUser(user);

    storeService.addStore(store);
    return modelAndView;
}

Web.xml、Spring-config、安全性 - 都很好,但有什么问题,问题的 prt scr:

已解决。我刚刚将 BindindResult 添加到我的 POST 方法中;)