5 Replies Latest reply on Jul 30, 2010 6:47 AM by moyphus

    How to call the Store procedure in jboss seam application

    palani.palanivelsway.gmail.com

      hi everybody i am new in jboos seam,


      how to call stored procedure in seam
      any help me it's very urgent


      ad,
      thanks

        • 1. Re: How to call the Store procedure in jboss seam application
          raphaufrj

          If you're using JPA with Jboss Seam will be:


            String sup_name ="Tortuga Trading";
                  BigDecimal sum = (BigDecimal)em.createNativeQuery("SELECT sum_total(?1) FROM DUAL")
                                .setParameter(1, sup_name)
                                .getSingleResult(); 
                  out.println("The total cost of the ordered products supplied by Tortuga Trading: " + sum +"<br/>");
          
          



          Regards,

          • 2. Re: How to call the Store procedure in jboss seam application
            serkan.s.eskici.online.nl

            You should make a Google search on Hibernate/JPA + Stored Procedure.

            • 3. Re: How to call the Store procedure in jboss seam application
              mauihoosier

              Insightful and incredibly helpful. Always good to know there are people out there who truly cherish helping the fellow man.

              • 4. Re: How to call the Store procedure in jboss seam application
                mauihoosier

                Palani - here is an example that I have used:


                '
                Query query = entityManager.createNamedQuery(pkgname.fnname);
                            query.setParameter(param1, param1);
                            bean = (Bean) query.getSingleResult();'


                The Bean is annotated like :


                '@Entity
                @NamedNativeQuery(name = pkgname.fnname, resultSetMapping = results, query = {? = call SCHEMANAME.pkgname.fnname(:param1)}, hints = {
                    @QueryHint(name = org.hibernate.callable, value = true),
                    @QueryHint(name = org.hibernate.readOnly, value = true) })
                @SqlResultSetMapping(name = results, entities = { @EntityResult(entityClass = BeanName.class) })


                '

                • 5. Re: How to call the Store procedure in jboss seam application


                  @NamedNativeQuery(name="storedProc",
                                    query="sp_get_department_utility(:param1, :param2)",
                                    hints={
                                                @QueryHint(value = "true", name="org.hibernate.callable"),
                                                @QueryHint(value = "true", name="org.hibernate.readOnly")})
                  @SqlResultSetMapping(name="resul", entities={
                            @EntityResult(entityClass = SysDepartments.class),
                            @EntityResult(entityClass = Employee.class),
                            @EntityResult(entityClass = ProductOrderLimitation.class),
                            @EntityResult(entityClass = ProductOrderLimitation.class),
                            @EntityResult(entityClass = ProductMaster.class)})





                  Query q=(Query) this.getEntityManager().createNamedQuery("storedProc")
                            .setParameter(":category", ParamUtil.getCategory())
                            .setParameter(":clientId", LoginUserInfo.getClientId());
                            int list = q.executeUpdate();
                  



                  It returns named query not found