move sql to entity