0 Replies Latest reply on Dec 3, 2007 5:10 PM by eroussel

    Link a user with the entities he/she created

      Hello,

      I'm fairly new the Seam and looking for some advice on achieving the following:

      Some tables (entities) in my application contain data that must be associated with the user that created the record.

      I got the part where the entities are annotated properly to describe the 1 to * relationship.

      The question I have is which one of the two following approaches Seam veterans would recommend to use (or if neither are appropriate, what's the alternative).

      Approach A would be to override the "persist" method in entityHome such as:

      public class myEntityHome extends EntityHome<MyEntity>
      {
       ...
       @In
       User user; // That's the entity with the user's data
      
       ...
       @Override
       public String persist() {
       this.getInstance().setSubmitter(user); // Recording who created this using the entity's setter
       return super.persist();
       }
      }
      


      Approach B would be to handle this in an "action" bean.

      Thanks.