Fixed some bug with JPA