Optional functional with hibernate