First you need to determine if it is DDL or DML. If you do not know, I recommend that you set hibernate.show_sql = true to capture an expression of abuse.
If it is DDL, then most likely it will be Hibernate, updating the scheme for you, and you need to additionally configure the hibernate.hbm2ddl.auto parameter as " update " or " none ", depending on whether you use the actual db or symbolic (only for reading), respectfully. You can use " validate " instead.
If this is DML, I would first determine if your code is for any reason modifying an instance that is still bound to an active Hibernate session. If this is the case, subsequent reading may result in discarding these changes without explicitly storing the object (Grails?). If so, consider eliminating the instance that caused the flash (or using transport objects instead).
Perhaps you are using any aspects or events of the Hibernate life cycle to provide object auditing? It can also lead to read-only access, which will trigger an insert or update.
It may turn out that you need to provide alternative mappings for the intruder class if the field updateability comes into play, but the code does everything exactly as you would like (this is unlikely; 0). If you are in the world of annotations, this can be difficult. If you are working with hbm.xml, it is easier to provide an alternative mapping.
source share