[PlayFramework]带有@Required的Blob将文件保存两次

[PlayFramework]带有@Required的Blob将文件保存两次,playframework,blob,Playframework,Blob,模型如下: @Entity public class Doc extends Model { public Blob tpl; } 控制器,如: public class DocController extends Controller { public static void saveDoc(@Required Blob tpl){ render(); // event no persistence op

模型如下:

    @Entity
    public class Doc extends Model {
        public Blob tpl;
    }
控制器,如:

    public class DocController extends Controller {
        public static void saveDoc(@Required Blob tpl){
           render();  // event no persistence operation
        }
    }

数据/附件中将包含2个上传文件。甚至在控制器操作中也没有持久性操作。

您可以将Doc对象直接传递到您的操作中(从视图中使用
Doc.tpl
,而不仅仅是
tpl
),然后对对象而不是Blob本身执行验证

@Entity
public class Doc extends Model {
    @Required
    public Blob tpl;
}

public class DocController extends Controller {
    public static void saveDoc(@Valid Doc doc){
       render();  // event no persistence operation
    }
}