@Produces(MediaType.APPLICATION_JSON)
public JSONPObject getPartyEntitiesByType(
@QueryParam("callback") String callback,
@QueryParam("typeId") long typeId, @QueryParam("q") String q) {
String hql = "from PartyEntity where partyType.id=? and name like ? order by name";
Page page = partyEntityManager.pagedQuery(hql, 1, DFAULT_PAGE_SIZE,
typeId, q.replace("_", "\\_") + "%");
List<PartyEntity> partyEntities = (List<PartyEntity>) page.getResult();
List<PartyEntityDTO> partyEntityDtos = new ArrayList<PartyEntityDTO>();
for (PartyEntity partyEntity : partyEntities) {
PartyEntityDTO partyEntityDto = new PartyEntityDTO();