Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring java.lang.IllegalArgumentException:尝试创建具有空实体的事件_Spring_Hibernate_Spring Boot_Persist_Modelattribute - Fatal编程技术网

Spring java.lang.IllegalArgumentException:尝试创建具有空实体的事件

Spring java.lang.IllegalArgumentException:尝试创建具有空实体的事件,spring,hibernate,spring-boot,persist,modelattribute,Spring,Hibernate,Spring Boot,Persist,Modelattribute,我尝试持久化此实体: @Entity public class Cliente extends Model { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Integer id; @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL) private Usuario usuario; @OneToOne(fetch = F

我尝试持久化此实体:

@Entity
public class Cliente extends Model {
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private Integer id;

  @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  private Usuario usuario;

  @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
  private org.loja.model.cesta.Cesta cesta;

  @OneToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
  @OrderColumn
  private List<org.loja.model.pedido.Pedido> pedidos;

  public Cliente() {
    this.usuario = new Usuario();
    this.cesta = null;
    this.pedidos = null;
  }
}
当我尝试提交数据时

我的控制器:

@RequestMapping(value = "/register", method=RequestMethod.GET)
public String formRegister(Model model) {
  model.addAttribute("command", new Cliente());
  return "register";
}

@RequestMapping(value = "/register", method=RequestMethod.POST)
@ResponseBody
public void doRegister(@ModelAttribute("cliente") Cliente object) throws Exception {
  home.register(object);
}

任何人都可以提示这里出了什么问题?

错误表明传递给saveorUpdate的对象是nul,您是否在rest调用中验证了该对象不为空?我在浏览器开发人员工具的tab network中检查,所有参数都在那里。在控制器中,当我尝试打印对象时,对象为空。
<form class="form-signin" id="form" method="post" th:object="${command}" th:action="@{/register}">
    <label for="username" class="sr-only">Username</label>
    <input type="text" th:field="*{usuario.username}" id="username" class="form-control" placeholder="Username" required autofocus>

    <label for="password" class="sr-only">Password</label>
    <input type="password" th:field="*{usuario.password}" id="password" class="form-control" placeholder="Password" required>

    <label for="firstName" class="sr-only">Nome</label>
    <input type="text" th:field="*{usuario.firstName}" id="firstName" class="form-control" placeholder="Nome" required>

    <label for="lastName" class="sr-only">Sobrenome</label>
    <input type="text" th:field="*{usuario.lastName}" id="lastName" class="form-control" placeholder="Sobrenome" required>

    <label for="email" class="sr-only">E-mail</label>
    <input type="email" th:field="*{usuario.email}" id="email" class="form-control" placeholder="E-mail" required>
</form>
java.lang.IllegalArgumentException: attempt to create event with null entity
@RequestMapping(value = "/register", method=RequestMethod.GET)
public String formRegister(Model model) {
  model.addAttribute("command", new Cliente());
  return "register";
}

@RequestMapping(value = "/register", method=RequestMethod.POST)
@ResponseBody
public void doRegister(@ModelAttribute("cliente") Cliente object) throws Exception {
  home.register(object);
}