信息:HHH000397:使用ASTQueryTranslatorFactory无法创建sessionFactory对象。[Ljava.lang.StackTrac

时间:2015-11-06 16:49:37

标签: hibernate-4.x

我在hibernate尝试创建会话工厂对象时出错,所以在try子句的businessClass方法中它跳转到:finally {session.close(); //它说我在那条线上有错误}

但发生这种情况是因为它无法创建我在日志文件中获得的会话工厂:

INFO: HHH000397: Using ASTQueryTranslatorFactory
Failed to create sessionFactory object.[Ljava.lang.StackTraceElement;@ae735
6 nov. 2015 17:01:30 org.apache.catalina.core.ApplicationDispatcher invoke
GRAVE: "Servlet.service()" pour la servlet Recuitment_App a lancé une exception
java.lang.NullPointerException
    at recuitment_core_app.B_compte.AuthentificationDelegate(B_compte.java:133)

现在我的业务方法:

  public long AuthentificationDelegate(){

            //if if if --> make a query & response Object //and driven string navigation
        //    if ( App_user.equals("recruiter")){
                  Session session = null;
                  Transaction tx = null;
                    Pojo_compte account_searched=new Pojo_compte();
                    System.out.println("7na 9bel mandekhlo try ha login:"+login+" pass:"+password); 
                    // account_searched.setId_compte(0);
                try{    
                session=HibernateSessionFactory.getSessionFactory().openSession();
                tx=session.beginTransaction();
                System.out.println("dkholna n try alors fin kyn mochkil !!");

                 //Using persistence object
                String rqt="from Pojo_compte as pj_compte where pj_compte.login=:login_c and pj_compte.password=:password_c ";
                //session.flush();
                Query query =session.createQuery(rqt);



                    //  .setString("login_c", this.login)
                    //  .setString("password_c",this.password);
            //   query.executeUpdate();
         // System.out.println(rqt);
                        if ( query.list().size() == 1){

                            account_searched=(Pojo_compte) query.list().get(0);


                  //initialise  model  bean with data founded in database !


                        }else { account_searched.setId_compte(new Long(0));}



                //  List<User> results = userDatabase.createQuery(
                  //         "select u from User u where u.username=:username and u.password=:password")
                 //       .setParameter("username", credentials.getUsername())
                 //     .setParameter("password", credentials.getPassword())
             //      .getResultList();                    

                }catch(HibernateException  he){
                    tx.rollback();
                    System.out.println(he.getMessage()+"hahowa msg");
                }

                finally{
                //  session.flush();
                    session.close();    
                }    




                return account_searched.getId_compte();

                  }
事实上,在我添加关系之前,这是完全没问题的:

<class name="Pojo_compte" table="compte" >
        <id name="id_compte" type="long" column="id_compte" >
            <generator class="sequence">
             <param name="sequence">compte_id_compte_seq</param>
            </generator>
        </id>

        <property
            name="date_creation"
            column="date_creation"
            type="date"
            not-null="false"
            length="13"
        />
        <property
            name="login"
            column="login"
            type="string"
            not-null="false"
            length="50"
        />
        <property
            name="status_compte"
            column="status_compte"
            type="string"
            not-null="false"
            length="30"
        />
        <property
            name="password"
            column="password"
            type="string"
            not-null="false"
            length="50"
        />
        <!-- password must be not null-->

        <many-to-one 
            name="validated_by"
            class="administration.Pojo_Manager"
            not-null="true" >
            <column name="id_manager"/>
        </many-to-one>
        <set name="inbox" inverse="true">
            <key column="id_receiver"></key>
            <one-to-many class="Pojo_inbox"  />
        </set>
        <set name="sent" inverse="true">
            <key column="id_sender"></key>
            <one-to-many  class="Pojo_inbox" />
        </set>

和:

<hibernate-mapping package="recuitment_core_app">
    <class name="Pojo_inbox" table="inbox">
        <id
            column="id_msg"
            name="id_msg"
            type="long"
        >
            <generator class="sequence" >
            <param name="sequence">inbox_id_msg_seq</param>
            </generator>
        </id>
        <property
            column="text_msg"
            name="texte_msg"
            not-null="false"
            type="text"
         />
        <property
            column="title_msg"
            length="200"
            name="titre_msg"
            not-null="true"
            type="string"
         />
        <property
            column="date_send"
            length="13"
            name="date_envoi"
            not-null="true"
            type="date"
         />
        <property
            column="msg_flag"
            length="30"
            name="msg_flag"
            not-null="true"
            type="string"
         />


        <many-to-one
            class="Pojo_compte"
            name="sender"
            not-null="true" >
            <column name="id_sender" />
        </many-to-one>
        <many-to-one
            class="Pojo_compte"
            name="receiver"
            not-null="true"
        >
            <column name="id_receiver" />
        </many-to-one>
    </class>
</hibernate-mapping>

可以从收件箱表创建fkeys到compte表(id_sender,id_receiver)吗?因为在我添加这些关系之前,这是完美的:/!

0 个答案:

没有答案