Fix bugs with JPA DB