在play框架控制器中使用pojo绑定时的持久性异常

Kar*_*ran 5 playframework

我有以下实体:

@Entity
public class Client extends Model{
   public String email;
   public String password;
}
Run Code Online (Sandbox Code Playgroud)

我有以下控制器:

public static void  clientSignUp(models.Client client)
{
     info("Client email" + client.email);
     info("Client password" + client.password);
     client.create();
}
Run Code Online (Sandbox Code Playgroud)

调用此控制器时,两个日志正确打印​​出来.但是client.create行错误与这个hibernate异常:

  PersistenceException occured : org.hibernate.PropertyAccessException: 
  could not get a field value by reflection getter of models.Client.email
Run Code Online (Sandbox Code Playgroud)

但是,当我稍微更改代码时:

   public static void  clientSignUp(models.Client client)
   {
    models.Client client2  = new Client();
    client2.email= client.email;
    client2.password = client.password;
    client2.create();
   }
Run Code Online (Sandbox Code Playgroud)

有用.有什么想法吗?

Gel*_*Luo 0

如果您将client.create();第一个版本更改为 该怎么办client.save();