6 Replies Latest reply on Aug 13, 2012 7:17 PM by calca

    hibernate.cfg.xml not found (JBPM5 / Install.demo)

    imadt

      Hi all,

       

      After i configured all files to connect jboss to Mysql Database (i followed this link : http://docs.jboss.org/jbpm/v5.3/userguide/ch.installer.html#d0e597)

       

      After i finished configuring files i'm trying now to run a sampl "Select" Query.

       

      but i found that there are no ihbernate.cfg.xml file on my folder installation. (normally it's supposed to be created by install.demo)

       

      Here is my Code lines to run the Query.

       

              Configuration configuration = new Configuration();

              SessionFactory  sessionFactory = configuration.configure().buildSessionFactory();

              Session session = sessionFactory.openSession();

              Transaction transaction = session.beginTransaction();

              org.hibernate.Query q = session.createQuery("from users");

              transaction.commit();

        • 1. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
          imadt

          Do any one can help me !!?

           

          I spent all the day trying to get Hibernate configured with Jboss7 but no luck.

           

          please need ur helo here. Thanks

          • 2. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
            calca

            Where are you runing this query? In your app? I think that as jBPM uses JPA you don't use an hibernate.cfg.xml file, but a persistence.xml.

             

            Regards,

             

            Demian

            1 of 1 people found this helpful
            • 3. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
              imadt

              Thank you so much Demian for your reply.

               

              i can see that jBPM use the JPA but after i run my code it's giving me :

               

              org.hibernate.HibernateException: /hibernate.cfg.xml not found

                        at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)

                 ....

               

              Can you give me a link where i can found how to use jBPM with Jboss/Hibernate ?

              • 4. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
                calca

                Well, I still don't understand what you are trying to achieve? What do you want to query?

                 

                To create a Query using JPA, you must create an EntityManager from one of the persistence units you have in persistence.xml.

                 

                EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

                 

                and then create an entity manager that will let you create a query.

                 

                But again, it would be good to know what you are trying to do in order to help you.

                 

                Thanks

                 

                Demian

                • 5. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
                  imadt

                  Demain,

                   

                  I have Jbpm5 with jBoss 7 well configured, right now i'm trying to excute a query that will Insert "a simple row" in my database table "users".

                   

                  Here is my code with JPA :

                   

                  EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa");

                  EntityManager em = emf.createEntityManager();

                  Query query = em.createQuery("SELECT c FROM users c");

                  List results = query.getResultList();

                  System.out.println(results);

                   

                  When i run this i get this error :

                   

                  java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: users is not mapped [SELECT c FROM users c]

                            at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:601)

                            at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:96)

                            at com.sample.ProcessTest.testProcess(ProcessTest.java:46)

                            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

                            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                            at java.lang.reflect.Method.invoke(Unknown Source)

                    ...

                   

                  I'm confused now i'm Using JPA but i get  org.hibernate.hql.ast.QuerySyntaxException: users is not mapped Error.

                   

                   

                  Hope that thinsg get clear for you now.

                   

                  And i really appreciate your help. Thank you in advance.

                  • 6. Re: hibernate.cfg.xml not found (JBPM5 / Install.demo)
                    calca

                    Well, there it says that Users is not mapped.

                     

                    If you want to query the users from task database (https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-core/src/main/java/org/jbpm/task/User.java)

                     

                    you can make "From User"

                     

                    and when creating the EntityManagerFactory, the persistence unit name is "org.jbpm.task"

                     

                    Jbpm uses two persistence units (you can check it in file persistence.xml, it should look like this https://github.com/calcacuervo/JBPM5-Samples/blob/master/human-tasks/src/test/resources/META-INF/persistence.xml) One is for human tasks persistence, and the other for jbpm runtime entities.

                     

                    Hope this helps,

                     

                    Demian