2011-12-06 3 views
0

私は、休止状態を使用するアプリケーションを持っています。 私は次のようでした:キャッシュを使用しているHibernateのリスト? - エンティティ属性を更新していません

私のMySQLデータベースてmanualyログインしてと同じクエリをやって休止状態に再びリストを使用し、いくつかの エンティティ
  • 内のフィールドを更新するデータベース
  • にいくつかのエンティティを一覧表示するリストを使用し

    リストされた休止状態のエンティティは更新されませんでした。 アプリケーションを閉じて開いた場合。エンティティが正しく更新されたことが示されます。

    デフォルトでは、何らかの種類のキャッシュを使用している休止状態ですか?エンティティを示しています

    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/XXX</property> 
    <property name="hibernate.connection.username">XXXXXXXXXX</property> 
    <property name="hibernate.connection.password">XXXXXXXXXX</property> 
    <property name="show_sql">true</property> 
    

    コード:

     Session s = HibernateUtil.getSession(); 
         Criteria c = s.createCriteria(Solicitacao.class, "s"); 
         //Add some Restrictions here 
         List<Solicitacao> ls = c.list(); 
         s.close(); 
    

    私のセッションの工場:私は私のhibernate.cfg.xmlでこれらの行を追加するためにしようと試み

    public class HibernateUtil { 
        private static SessionFactory sessionFactory = null; 
        static { 
         // Configurações iniciais de caminho dos diretórios e arquivos 
         URL url = HibernateUtil.class.getProtectionDomain().getCodeSource().getLocation(); 
         File myFile = null; 
         try { 
          myFile = new File(url.toURI()); 
         } catch (Exception ex) { 
    
         } 
         File dir = myFile.getParentFile(); 
         File xml = new File(dir, "hibernate.cfg.xml"); 
         /* 
         * sessionFactory = new AnnotationConfiguration() .configure("br/com/netradiobrasil/pcp/" + 
         * "hibernate/hibernate.cfg.xml") .buildSessionFactory(); 
         */ 
         sessionFactory = new AnnotationConfiguration().configure(xml).buildSessionFactory(); 
        } 
    
        public static Session getSession() { 
         return sessionFactory.openSession(); 
        } 
    } 
    

    <property name="hibernate.cache.use_query_cache">false</property> 
    <property name="hibernate.cache.use_second_level_cache">false</property> 
    <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 
    

    また、使用を試みました:session.setCacheMode( CacheMode.IGNORE)

    それでも

  • 答えて

    0

    - C3P0はイムは申し訳ありませんが、私は最初のクエリの後に近くのセッションを行いました

    <property name="hibernate.c3p0.min_size">5</property> 
    <property name="hibernate.c3p0.max_size">40</property> 
    <property name="hibernate.c3p0.timeout">300</property> 
    <property name="hibernate.c3p0.max_statements">50</property> 
    <property name="hibernate.c3p0.idle_test_period">100</property> 
    
    0

    は私が

    を推測してみましょう私の問題を解決するためのdidntこの

    Session s = HibernateUtil.getSession(); 
    Criteria c = s.createCriteria(Solicitacao.class, "s"); 
    //Add some Restrictions here 
    List<Solicitacao> ls = c.list(); 
    

    を実行した後は、手動でデータベースのエントリを変更し、クエリをreran?はいの場合は、セッションを閉じてからコードを再実行できますか?私のhibernate.cfg.xmlの中にこれらの行を追加

    +0

    私の問題を修正できます.......私は別のものを作成しますセッションと同じクエリをreran – fredcrs

    関連する問題