In a read-only process, hibernate is still modifying the database.

Solution Verified - Updated -

Issue

  • In a read-only transaction, UPDATE statements are appearing in the logs.

Environment

  • Hibernate
  • Java Persistence API (JPA)

  • Pseudo code

    @Transactional(propagation =  Propagation.REQUIRED, readOnly = true)
    public String test (){
    Entity ent = daoX.findAll().get(0);
    ent.setDescription(“NEW  DESCRIPTION”);
    daoX.flush();
    }
    

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.