add jpa annotations and some logic