2 Replies Latest reply on Aug 25, 2014 1:52 PM by Michael Kucinski

    Is it possible to combine an Account with the Entity that it maps to?

    Michael Kucinski Newbie

      Hey guys, I have a quick question. Is it possible to, instead of mapping a POJO Account object to an entity, create a stane-alone entity which acts as an account? It seems less redundant when working with JPA.

       

      -Michael

        • 1. Re: Is it possible to combine an Account with the Entity that it maps to?
          Pedro Igor Master

          Hey Michael,

           

              We do support the following mapping. Suppose you have a custom Account type as follows:

           

          public class MyUser extends AbstractIdentityType implements Account {
          
              @AttributeProperty
              private Person person;
          
              // getter and setter
          }
          
          
          

           

              Here, Person is a reference to a specific entity. Not necessarily managed by PicketLink, but any entity you want to have a reference to.

           

              Now, take a look at the entity used to map the MyUser account type:

           

          @Entity
          @IdentityManaged(MyUser.class)
          public class MyUserTypeEntity extends IdentityTypeEntity {
          
               @OneToOne (cascade = CascadeType.ALL)
               @AttributeValue
               private Person person;
          
               // getter and setter
          }
          
          
          


              With that, every time you load a MyUser from your identity store, a Person instance will be available. The same thing when storing MyUser and setting a Person. It will be automatically persisted.


              You can check a working example from the PicketLink AngularJS Quickstart.


          Regards.

          1 of 1 people found this helpful
          • 2. Re: Is it possible to combine an Account with the Entity that it maps to?
            Michael Kucinski Newbie

            Thank you for the example; it was a mapping I would have never thought of myself! I'll will implement it today and see how it works.

             

            -Michael