EntityManager em = EMRepository.INSTANCE.getEM(sessionToken);
Class<?> entityClass = EntityUtils.getEntityClass(entityClassName, em);
log.debug("DELETE: entityClass" + entityClass);
EntityMetadata entityMetadata = EntityUtils.getEntityMetaData(entityClass.getSimpleName(), em);
MetamodelImpl metaModel = (MetamodelImpl) em.getEntityManagerFactory().getMetamodel();
EmbeddableType keyObj = null;
Object key = null;
id = java.net.URLDecoder.decode(id, "UTF-8");
if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
keyObj = metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType());
key = JAXBUtils.toObject(id, keyObj.getJavaType(), mediaType);
} else {
ObjectMapper mapper = new ObjectMapper();
key = mapper.convertValue(id, entityMetadata.getIdAttribute().getBindableJavaType());
}