Please make this more understandable, move sql to the entity