rewrite jpa and endpoints