code: public static void setObjectToReadWrite(final Object target, SessionFactory sessionFactory) {
          Session session = sessionFactory.getCurrentSession();
          if (!canModifyReadWriteState(session, target)) {
              return;
          }
  
          SessionImplementor sessionImpl = (SessionImplementor) session;
          EntityEntry ee = sessionImpl.getPersistenceContext().getEntry(target);
  
          if (ee == null || ee.getStatus() != Status.READ_ONLY) {
              return;
          }
  
          Object actualTarget = target;
          if (target instanceof HibernateProxy) {
              actualTarget = ((HibernateProxy)target).getHibernateLazyInitializer().getImplementation();
          }
  
          session.setReadOnly(actualTarget, false);
          session.setHibernateFlushMode(FlushMode.AUTO);
          incrementVersion(target);
      }
docs: Sets the target object to read-write, allowing Hibernate to dirty check it and auto-flush changes.
  
  @see #setObjectToReadyOnly(Object, org.hibernate.SessionFactory)
  
  @param target The target object
  @param sessionFactory The SessionFactory instance