Help on setting hibernate's flush property.
I am getting below error.
Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
I am just confused how would i set the flush property.
<property name="org.hibernate.FlushMode" value="COMMIT"/>
<property name="org.hibernate.flushMode" value="COMMIT"/>
<property name="org.hibernate.flushMode" value="commit"/>
<property name="hibernate.flushMode" value="COMMIT"/>
What is the proper way to set the property without using any java code?
I tried in this way but still its showing the same error.
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<property name="org.hibernate.flushMode" >commit</property>
<mapping class="com.example.User" />
</session-factory>
</hibernate-configuration>
correct is <property name="org.hibernate.flushMode" value="COMMIT"/>.
But your problem it's not correct value for flushMode. This message is from exception that you have. It doesn't connected to flushMode directly. You do some operation that might throw this exception. For example : you might try execute some update query with read-only transaction. Check the dao/service method that throws this exception for correct transaction configuration , for operations that you try to do inside one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With