Fixing JPA implementation. and security