java - Does Hibernate's @DynamicUpdate work with Blobs? -


i'm using hibernate 4.2.3 , have class similar following:

@entity @dynamicinsert @dynamicupdate @selectbeforeupdate public class test {      @id     private biginteger theid;      @lob     @basic(fetch = fetchtype.lazy)     @jsonignore     private blob data;      @lob     @basic(fetch = fetchtype.lazy)     @jsonignore     private blob otherdata;      // getters , setters....   } 

the sql generating update includes data column, though hasn't changed. (to precise, object, detach it, read data , use generate otherdata, set , call saveorupdate on session.)

can explain why happen? functionality work blobs? i've searched documentation found none.

ps i'm not using @dynamicupdate performance reasons. know questionable use standpoint.

the safest , portable (between different databases , jpa providers) way achieve real lazy loading of lobs create an artificial lazy one-to-one association between original entity , new 1 move lob.

this approach suitable other kinds of optimizations well, example when want enable second-level caching of complex entity, few columns of entity updated frequently. extract columns separate non-second-level-cacheable entity.

however, keep in mind general pitfalls specific one-to-one associations. basically, either map mandatory (optional = false) one-to-one association @primarykeyjoincolumn or make sure foreign key in entity (table) declares lazy association (in case original entity lob moved out). otherwise, association eager, defeating purpose of introducing it.


Comments