是否可以将Play Framework的CRUD模块配置为遵守@Column(unique = true)注释?
|
我正在使用Play的CRUD模块创建一组简单的管理屏幕。我的模型之一是用户,我想对电子邮件字段实施唯一约束。
代码如下:
public class User extends Model {
@Email
@Required
@Column(unique=true)
public String email;
管理屏幕正确显示-当我尝试破坏唯一性时(通过使用已经使用过的电子邮件保存用户),我收到此错误(在浏览器中):
Execution exception
PersistenceException occured : org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
In {module:crud}/app/controllers/CRUD.java (around line 100)
96:
} catch (TemplateNotFoundException e) {
97:
render(\"CRUD/show.html\", type, object);
98:
}
99:
}
100:
<b>object._save();</b>
101:
flash.success(Messages.get(\"crud.saved\", type.modelName));
102:
if (params.get(\"_save\") != null) {
103:
redirect(request.controller + \".list\");
104:
}
105:
redirect(request.controller + \".show\", object._key());
106:
}
我可以使用CRUD模块和列唯一性注释进行任何调整吗?
没有找到相关结果
已邀请:
2 个回复
佩疵瓦
疼嘶桐