0 Replies Latest reply on Apr 15, 2006 5:38 AM by Stefan Kanev

    Enforcing more referential rules in EJB3.0

    Stefan Kanev Newbie


      I'm working on a small system and I want to achieve the following results. I want to have two entities, User and Group, which basically look like this:

      class @Entity User {
       @Id int id;
       @ManyToOne(option=false) Group group;

      class @Entity Group {
       @Id int id;
       @OneToMany(mappedBy="group") List<User> users;
       @OneToOne User owner;

      What I want, is to be as sure as possible that if user is the owner of group then user.getGroup.getOwner = user and group.getOwner.getGroup = group.

      How is the best way to add those constraints on entity level (and not in the session bean logic, since I want to add another layer of security here).