working hibernate with constraints