We're updating the issue view to help you get more done. 

Update Without update

Description

The application is a web application that has a filter to open and close the transaction with each request.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 /** * This filter open and close HibernateTransaction */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Session session = HibernateSessionFactory.getSession(); Transaction tx = null; try { logger.debug("Starting a database transaction"); tx = session.beginTransaction(); // Call the next filter (continue request processing) chain.doFilter(request, response); if (tx.isActive()) { // Commit if needed and cleanup logger.debug("Committing the database transaction"); tx.commit(); } } catch (Throwable ex) { logger.debug("failed to process the request!", ex); if ((tx != null) && tx.isActive()) tx.rollback(); if (session.isOpen()) session.close(); ex.printStackTrace(); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 /** * Create if necessary, and return the singleton Hibernate SessionFactory. */ public static SessionFactory getSessionFactory() { try { if (sessionFactory == null) { // configuration settings from hibernate.cfg.xml Configuration configuration = new Configuration().configure(CONFIG_FILE_LOCATION); StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); } return sessionFactory; } catch (Throwable ex) { System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } }
1 2 3 4 5 6 7 8 9 /** * This method use sessionFactory to get current session */ @Override public T getById(PK pk) { T entity = (T) getSessionFactory.getSession().get(getTypeClass(), pk); logger.info("getById loaded successfully, Entity details=" + entity + " / PK=" + pk); return entity; }
1 2 3 4 5 6 7 8 9 /** * This method get object and set a new value into property [used]. */ @Override public Downloader setUsedById(Long id) { Downloader down = getById(id); down.setUsed(1); return down; }

The problem occurs when the process is finished and the filter commits the transaction. For some reason hibernate does the uptime in the table, even without having given an update.

Hibernate output:

1 Hibernate: update tb_aihcis_download_info set CLIENT_ID=?, DH_INFO=?, SELECTED_CONFIG_ID=?, SELECTED_VERSION_ID=?, used=?, USER_NAME=? where PK_DOWNLOAD_INFO=?

Environment

tested with SQL Server 2008, JVM 1.8.0_161, Windows 7, Hibernate Core 4.3.7 and Eclipse Oxygen.

Status

Assignee

Unassigned

Reporter

Vinícios Rodrigues

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.3.7

Components

Affects versions

4.3.7

Priority

Major