rebased on beangle entitydao