Hibernate does not consult the last record in the database

0

A batch is trying to consult a record of the database to later update it, but simultaneously the user modifies that same record and manages to commit, since the batch was already executing query and obtains the old record (cache first level) and overwrite what the user updated.

How can I make the search of the batch force search the database?

Query that performs the batch:

ChildLineDTO result = childLineDAO.find(entityId);

Metodo find:

K entityFind  = (K) getHibernateTemplate().get(class1, entityId);
    
asked by Diana 05.10.2017 в 17:06
source

1 answer

0

I found the solution to my problem, I worked creating a new session and making the query.

Session session = getHibernateTemplate().getSessionFactory().openSession();
        session.beginTransaction();
        K entityFind = (K) session.get(class1, entityId);
    
answered by 09.10.2017 в 21:25