0

I'm beginer in Hibernate and Spring MVC, and i have a repetitive problem on retrieving data, sometimes when i refresh my page or just submit a form, i get old data that i had updated or even deleted.

Here is my configurations file of hibernate :

<hibernate-configuration>
<session-factory>
 <!-- Database connection settings -->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3306/cotaDB18</property>
    <property name="connection.username">root</property>
    <property name="connection.password"></property>

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>

    <!-- Disable the second-level cache  -->
    <!-- <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> -->

    <property name="hibernate.connection.isolation">4</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">update</property>

</session-factory>

I retrieve data like this :

@SuppressWarnings("unchecked")
@Override
public List<Tache> getTachesByPhase(int idPhase) {
    Session session =  HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    String hql = "From Tache T where T.phase=" + idPhase + " Order by T.index";
    Query query = session.createQuery(hql);
    return query.list();
}

Please i need your help, i don't find the solution

4
  • You also need to show us how you retreive this data.
    – RandomSeed
    Jul 28, 2014 at 9:53
  • I think this happens when HTTP-POST scope is not broken. Seldom when you refresh your page the old computation you did also gets a refresh. Is that the problem you are facing? Jul 28, 2014 at 9:58
  • @DarshanLila Yes that's it ! is not common but generaly it happens when i refresh or submit a form with a post method
    – Ouda
    Jul 28, 2014 at 10:03
  • @RandomSeed here is the method of retrieving data
    – Ouda
    Jul 28, 2014 at 10:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.