replace query api with criteria api