Use the toLong()
Or use the community commons for building xPaths, for example
XPath<EntityProxy> xPath = XPath.create(context, module.proxies.EntityProxy.class);
xPath.eq(EntityProxy.MemberNames.EntityProxy_EntityProxy2, EntityProxy2.entityName, EntityProxy2.MemberNames.Name, NameString);
List<EntityProxy> entityProxyList = xPath.all();