-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hiberante update problem
PostPosted: Thu Dec 07, 2006 10:20 am 
Newbie

Joined: Thu Dec 07, 2006 9:28 am
Posts: 2
I can't get the real-data on my page after update ,the data is old.but the database is updated ,I can see on mysql command line.

sometimes I refresh the page the data is new,and refresh again the data is old,it's mutative,strange,strange..

hiberante 3.1
mysql 4.0.20a-nt

my hibernate.cfg.xml:




Code:
<hibernate-configuration>

<session-factory>
   <property name="connection.username">root</property>
   <property name="connection.url">
      jdbc:mysql://localhost:3306/hzsos?useUnicode=true&amp;characterEncoding=UTF-8
   </property>
   <property name="dialect">
      org.hibernate.dialect.MySQLDialect
   </property>
   <property name="myeclipse.connection.profile">mysql</property>
   <property name="connection.password"></property>
   <property name="connection.driver_class">
      com.mysql.jdbc.Driver
   </property>
   <property name="show_sql">true</property>




   <mapping resource="com/hzsos/common/pojo/CustomList.hbm.xml" />
   <mapping resource="com/hzsos/common/pojo/CustomListItem.hbm.xml" />
   <mapping resource="com/hzsos/common/pojo/Business.hbm.xml" />

</session-factory>

</hibernate-configuration>




udpate code:

Code:

   public void updateBusiness(BusinessForm form) {
      
      Transaction trans = null;
      try{
         
         Business business = businessDAO.findById(form.getId());
         business.setArea(form.getArea());
         business.setCompany(form.getCompany());
         
         trans = session.beginTransaction();
         businessDAO.update(business);
         session.flush();
         trans.commit();

         
      }catch(RuntimeException e){
         trans.rollback();
      }      
   }



Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 4:23 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
commit automatically flushes the session. try removing that session.flush call.

if that doesn't work, check your logs to see if you are actually sending update statements to the database, then check your logs to see if your page is reading the data from the database or reading it cached

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 07, 2006 10:40 pm 
Newbie

Joined: Thu Dec 07, 2006 9:28 am
Posts: 2
thanks,kochcp

I checked, update statements is sent to the database,and the table is really updated.

I'm not sure is it used second-level cache,in my hibernate.cfg.xml ,I did not config the cache.

here is my hiberante configure log:

cfg.Environment 479 ) Hibernate 3.1.3
(cfg.Environment 509 ) hibernate.properties not found
(cfg.Environment 525 ) using CGLIB reflection optimizer
(cfg.Environment 555 ) using JDK 1.4 java.sql.Timestamp handling
(cfg.Configuration 1308) configuring from resource: /hibernate.cfg.xml
(cfg.Configuration 1285) Configuration resource: /hibernate.cfg.xml
(cfg.Configuration 469 ) Reading mappings from resource: com/hzsos/common/pojo/CustomList.hbm.xml
(cfg.HbmBinder 309 ) Mapping class: com.hzsos.common.pojo.CustomList -> hzsos_customlist
(cfg.Configuration 469 ) Reading mappings from resource: com/hzsos/common/pojo/CustomListItem.hbm.xml
(cfg.HbmBinder 309 ) Mapping class: com.hzsos.common.pojo.CustomListItem -> hzsos_customlistitem
(cfg.Configuration 469 ) Reading mappings from resource: com/hzsos/common/pojo/Business.hbm.xml
(cfg.HbmBinder 309 ) Mapping class: com.hzsos.common.pojo.Business -> hzsos_business
(cfg.Configuration 1419) Configured SessionFactory: null
(cfg.HbmBinder 2349) Mapping collection: com.hzsos.common.pojo.CustomList.items -> hzsos_customlistitem
(connection.DriverManagerConnectionProvider 41 ) Using Hibernate built-in connection pool (not for production use!)
(connection.DriverManagerConnectionProvider 42 ) Hibernate connection pool size: 20
(connection.DriverManagerConnectionProvider 45 ) autocommit mode: false
(connection.DriverManagerConnectionProvider 80 ) using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/hzsos?useUnicode=true&characterEncoding=UTF-8
(connection.DriverManagerConnectionProvider 86 ) connection properties: {user=root, password=****}
(cfg.SettingsFactory 77 ) RDBMS: MySQL, version: 4.0.20a-nt
(cfg.SettingsFactory 78 ) JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.1-alpha ( $Date: 2004/02/06 17:15:32 $, $Revision: 1.27.4.29 $ )
(dialect.Dialect 103 ) Using dialect: org.hibernate.dialect.MySQLDialect
(transaction.TransactionFactoryFactory 31 ) Using default transaction strategy (direct JDBC transactions)
(transaction.TransactionManagerLookupFactory 33 ) No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
(cfg.SettingsFactory 125 ) Automatic flush during beforeCompletion(): disabled
(cfg.SettingsFactory 129 ) Automatic session close at end of transaction: disabled
(cfg.SettingsFactory 136 ) JDBC batch size: 15
(cfg.SettingsFactory 139 ) JDBC batch updates for versioned data: disabled
(cfg.SettingsFactory 144 ) Scrollable result sets: enabled
(cfg.SettingsFactory 152 ) JDBC3 getGeneratedKeys(): enabled
(cfg.SettingsFactory 160 ) Connection release mode: auto
(cfg.SettingsFactory 184 ) Maximum outer join fetch depth: 2
(cfg.SettingsFactory 187 ) Default batch fetch size: 1
(cfg.SettingsFactory 191 ) Generate SQL with comments: disabled
(cfg.SettingsFactory 195 ) Order SQL updates by primary key: disabled
(cfg.SettingsFactory 338 ) Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
(ast.ASTQueryTranslatorFactory 24 ) Using ASTQueryTranslatorFactory
(cfg.SettingsFactory 203 ) Query language substitutions: {}
(cfg.SettingsFactory 209 ) Second-level cache: enabled
(cfg.SettingsFactory 213 ) Query cache: disabled
(cfg.SettingsFactory 325 ) Cache provider: org.hibernate.cache.EhCacheProvider
(cfg.SettingsFactory 228 ) Optimize cache for minimal puts: disabled
(cfg.SettingsFactory 237 ) Structured second-level cache entries: disabled
(cfg.SettingsFactory 257 ) Echoing all SQL to stdout
(cfg.SettingsFactory 264 ) Statistics: disabled
(cfg.SettingsFactory 268 ) Deleted entity synthetic identifier rollback: disabled
(cfg.SettingsFactory 283 ) Default entity-mode: pojo
(impl.SessionFactoryImpl 154 ) building session factory
(config.Configurator 126 ) No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: file:/D:/jakarta-tomcat-5.0.30/work/Catalina/localhost/hzsos/loader/ehcache-failsafe.xml
(impl.SessionFactoryObjectFactory 82 ) Not binding factory to JNDI, no JNDI name configured


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.