combine entityManeger methods with standard play methods
I need extend delete()
action from playframework Model class and I have to use EntityManager and nativeQuery. I have not figured out yet what playframework does exactly with a session (i guess it does), but it seems that this query, before super.delete()
, was not effected. Does anybody have some thoughts about that?
@Entity
public cl开发者_C百科ass MyModel extends Model {
...
@Override
public Tag delete() {
final Query deleteLinksQuery = Tag.em().createNativeQuery("some query here");
int res = deleteLinksQuery.executeUpdate();
// here res=1 i.e. it works but it seems doesn't save to db
return super.delete();
}
}
I tried doing MyModel.em().flush();
after updating the executing the query, but it has'n worked.
we would need to see the query to be able to know why it may be failing. The code seems correct, so I would blame it on wrong JQL.
That said, I would suggest using @PreRemove and @PostRemove annotations on methods to launch the query. It keeps the code cleaner.
精彩评论