3 Replies Latest reply on Sep 14, 2008 8:16 AM by thejavafreak

    How can i @In Seam componet to drl?

    baobaotuo

      I want to fetch data from database for using in LHS.So hao can i @In dataDAO into drl?


      3Q

        • 1. Re: How can i @In Seam componet to drl?
          thejavafreak

          What you can do is expose your dao to drl from your Seam component.

          • 2. Re: How can i @In Seam componet to drl?
            baobaotuo
            What do you mean "expose"?

            If I hava a DAO "UserDAO" which is a seam compnent that is annotated with "@Name("userDAO")",

            @Name("userDAO")
            public class UserDAO{
              @In
              EntityManager entityManger;
             
              public User find(Long id){
                  return entityManager.createQuery("SELECT user FROM User user WHERE user.id = :id").setParameter("id",id).getSingleResult();
              }
            }
            I can just use it in drl as below?

            rule "test"
                no-loop;
            when
                c: PermissionCheck(name == "User",action=="manage");
                admin : UserDAO.find(1);
                Member(memberId : id -> id.equals(admin.id));
            then
                System.out.println("You are admin!");
                c.grant();
            end;

            Above code iss just a simple show case.

            I am new to drool.

            Thank for your help,Joshua Partogi.
            • 3. Re: How can i @In Seam componet to drl?
              thejavafreak

              You can not do that liu lei. You have to expose the variable/object to drools instead.