3 Replies Latest reply on Nov 9, 2009 6:47 PM by walterjwhite

    User and Role Permissions with JPA

    walterjwhite

      I was wondering since the annotations for the user and role classes allow developers to setup a truly relational database, why can't the permission entities also be relational?


      The suggested type is java.lang.String which works, but using the foreign key relationship would be advantageous when using the JpaIdentityStore in conjunction with the JpaPermissionStore.



      I haven't looked closely enough at the JpaPermissionStore to see if it does this or not, so if it already works this way, I will give that a shot.



      Thanks,
      Walter

        • 1. Re: User and Role Permissions with JPA

          Walter White wrote on Nov 09, 2009 04:23:


          I was wondering since the annotations for the user and role classes allow developers to setup a truly relational database, why can't the permission entities also be relational?


          I see no relationship between annotations for the user and role classes and truly relational databases.




          The suggested type is java.lang.String which works, but using the foreign key relationship would be advantageous when using the JpaIdentityStore in conjunction with the JpaPermissionStore.


          Not sure what do you mean here... The suggested type for what exactly? where would you like to use a foreing key?



          I haven't looked closely enough at the JpaPermissionStore to see if it does this or not, so if it already works this way, I will give that a shot.


          Thanks,
          Walter


          Again, not sure what do you mean...but good luck...

          • 2. Re: User and Role Permissions with JPA
            stefanotravelli

            It works.


            I'm using this setting in my application.
            I submitted a couple of patch to fix some minor issues that are included since Seam 2.1 (see jbseam://3672, jbseam://3619) and now I'm happy with the (undocumented) feature.


            Basically, what you have to do is simply annotate with @PermissonRole your @ManyToOne relation with the Role entity, and with @PermissionUser the @ManyToOne relation with the User entity.


            Hope this helps.


            stefano

            • 3. Re: User and Role Permissions with JPA
              walterjwhite

              Stefano,


              Sweet, I will give that a try later.  I don't have permissions fully setup to know if that will work, but might as well make the quick switch now and write some comments so I can pick that up whenever I get permissions fully integrated.



              Thanks,
              Walter