I store my entities in the exist xml database and I use a file name (resource id) as an ID of an entity. Example: String xquery = "for $movie in collection('/db/movie')//movie " ...