PlayFrameWork:Ebean删除错误

时间:2015-02-24 06:15:56

标签: java playframework ebean

关于这个 QUESTION,我没有得到任何帮助,所以想以另一种方式解释它。

所以我有一个model用于发布一个wallpost和一个删除选项,可以通过 @id stream_post_id)删除它

以下是我的模特

import play.db.ebean.Model;


 @Entity   
 @Table(name="stream_post_simple")
 @SequenceGenerator(name="stream_post_id", sequenceName="stream_post_stream_post_id_seq", allocationSize=1)

public class SimplePost extends Model implements Post, Broadcastable, PostSerialiser {
    @Id
    @Column(name="stream_post_id")
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator="stream_post_id")
    protected Long id;

    @Basic
    @Column(name="post")
    protected String post;

    @Column(updatable=false, insertable=false)
    @Temporal(TemporalType.TIMESTAMP)
    protected Calendar posted = Calendar.getInstance();

    @ManyToOne
    @JoinColumn(name="account_id")
    @Column(name="account_id")
    protected Account account;

    @ManyToOne
    @JoinColumn(name="poster_id")
    @Column(name="poster_id")
    protected Account poster; 

以下是我的删除方法

public static Result deletePostOnly(Long postId) {

    //check if post can be deleted with this user
    SimplePost post = SimplePost.find.byId(postId);
    if(post == null) {
        return badRequest();
    }

    UserAccount account = Secured.getCurrentUser();
    if(!(post.getPostUserId().equals(account.getId()))) {
        return badRequest();
    }

    try {
       post.delete();   //ebean delete     
       post.save();
    } catch (Exception ex) {
       ex.printStackTrace();
    }

 return ok("ok");
}

但这不起作用并给我一个错误

ERROR Executing DML bindlog[]error [No value specified for parameter 5.]

我不知道自己哪里出错了。 非常感谢任何帮助

0 个答案:

没有答案