In relation to this QUESTION, I haven't got any help so was thinking to explain it in another way.
So I have a model
for a posting a wallpost and a delete option to delete it by @id (stream_post_id
)
Following is my model
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;
Following is my delete method
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");
}
BUT This is not working and giving me an error as:
ERROR Executing DML bindlog[]error [No value specified for parameter 5.]
I don't know where I am going wrong. Any help is much appreciated thanks