Using Enum in Hibernate causes a choice, followed by an update statement

I have a mapped entity that has an enum property. By launching the log file, whenever I run the select statement for such an object, the result is the next update immediately. 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 will disappear. The enumeration is assigned through the enum converter class, which I copied from a well-known book. So I don’t know if I can just copy and paste the code. This is how it is declared in the hbm file.

<typedef class="mypackage.HbnEnumConverter" name="the_type">
    <param name="enumClassname">mypackage.TheType</param>
</typedef>

Can you indicate a direction to investigate this? Also, what are the consequences of updating = false in the sleep mode field?

thank

+5
1

Hibernate , .

, , .

- .

 class Entity{

   public YourEnum getEnum() {
    return yourEnum==null?YourEnum.SOME_VALUE:....;
   }
 }

, , Enum.equals false (null, null) case?

equals true, , , hibernate equals, , .

+2

All Articles