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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content