I have a mapped entity wich has an enum property. By loking at log file, whenever I run a select statement on such entity, the result is an immediately following update. For example if my result set contains 100 records, then I have:
[INFO org... select...]
[INFO org... update... where id=?]
[INFO org... update... where id=?]
.... repeated 100 times
If I mark the property as update=false the problem disappear. The enum is assigned trough an enum converter class, which I copied from a well known book. So I don't know if I just copy and paste the code. Here it is how is declared on hbm file.
<typedef class="mypackage.HbnEnumConverter" name="the_type">
<param name="enumClassname">mypackage.TheType</param>
</typedef>
Can you point out a direction to investigate this ? Beside, what are the consequences of having update=false on hibernate field ?
thanks
Hibernate will generate an update if your object marked as dirty.
See logs to see if hibernate marks your object as dirty.
if you have something similar to below.
class Entity{
public YourEnum getEnum() {
return yourEnum==null?YourEnum.SOME_VALUE:....;
}
}
Or maybe in your Enum.equals method you are returning false for probably equals(null,null) case?
equals method should return true if the compared objects are same and false otherwise as hibernate uses equals method to decide if the object is dirty or not.
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