Refactor some JPA-related stuff.