我的模特:
@Entity(name = "WORKFLOW_ROLE")
public class WorkflowRole extends GenericModel {
@Id
@Column(name = "IDNR", unique = true, nullable = false, precision = 22, scale = 0)
@Required
@Min(0)
public long id;
}
我的控制器动作:
public static void postNewRole(@Valid models.WorkflowRole role) {
try
{
role.workflow = models.Workflow.findById(role.workflow.id);
if (validation.hasErrors()) {
params.flash(); // add http parameters to the flash scope
validation.keep(); // keep the errors for the next request
newRole();
}
role.create();
flash.success("Rolle erstellt");
index();
}
catch (Exception e)
{
params.flash();
validation.keep();
flash.put("error", e.getMessage());
newRole();
}
}
@6chopgia8
Internal Server Error (500) for request POST /workflowrole/postnewrole
Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException: Unexpected Error
play.exceptions.UnexpectedException: Unexpected Error
at play.data.validation.ValidationPlugin.beforeActionInvocation(ValidationPlugin.java:80)
at play.plugins.PluginCollection.beforeActionInvocation(PluginCollection.java:639)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:134)
at Invocation.HTTP Request(Play!)
Caused by: play.exceptions.UnexpectedException: Unexpected Error
at play.db.jpa.JPAPlugin.bind(JPAPlugin.java:84)
at play.plugins.PluginCollection.bind(PluginCollection.java:579)
at play.data.binding.Binder.bind(Binder.java:112)
at play.mvc.ActionInvoker.getActionMethodArgs(ActionInvoker.java:651)
at play.data.validation.ValidationPlugin$Validator.validateAction(ValidationPlugin.java:117)
at play.data.validation.ValidationPlugin.beforeActionInvocation(ValidationPlugin.java:72)
... 3 more
Caused by: java.lang.NumberFormatException: For input string: "sdf"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:410)
at java.lang.Long.parseLong(Long.java:468)
at play.data.binding.Binder.internalDirectBind(Binder.java:612)
at play.data.binding.Binder.directBind(Binder.java:529)
at play.db.jpa.JPAPlugin.bind(JPAPlugin.java:76)
... 8 more
是否有人在播放1.2.5中遇到与通用模型绑定类似的问题?
答案 0 :(得分:1)
编辑:是的,这似乎是一个错误。补丁:https://gist.github.com/4242156
尝试将您的ID设为长而不是长 - 我怀疑这就是活页夹崩溃的原因。原始变量有特殊的逻辑 - 我认为你的案例证明了一个错误。但是,我认为如果切换到Long,代码应该按预期工作。
通常,您应该避免数据库绑定对象的原始值,除非您可以100%确定数据库中没有空值。 (但你的代码应该有效 - 所以有一个bug)
答案 1 :(得分:0)
确保路由是使用POST定义的,而不是GET。 您应该发布完整的代码,以便更容易查明问题。