开发者

When calling CRUD check if "parent" exists with read or join?

All my entities can not be deleted - only deactivated, so they don't appear in any read methods (SELECT ... WHERE active=TRUE).

Now I have some 1:M tables on this entities on which all CRUD operations can be executed.

What is more efficient or has better performance?

My first solution: To add to all CRUD operations:

UPDATE ... JOIN entity e ... WHERE e.active=TRUE

My second solution: Before all CRUD operations check if entity is active:

if (getEntity(someId) != null) {
    //do some CRUD
}

In getEntity there's just SELECT * FROM entity WHERE id=? AND active=TRUE.

Or any other solu开发者_运维百科tion, recommendation,...?


Second, plus an active second level cache ;) Chance is that the object already is in memory. Chance is acutally pretty high.


I would move all deactivated entities to a separate table and not worry about the entity being active.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜