Simplify NameIdDao and add optimistic locking to it.