-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: BLOB fields always dirty after calling getter ?
PostPosted: Sat Sep 20, 2008 3:35 pm 
Newbie

Joined: Sat Sep 20, 2008 3:10 pm
Posts: 2
Hi,

i use hibernate as the persistence provider in the current sun glassfish (ejb3-container). Hibernate does modify the entity by ONLY calling the getter of the BLOB-field:

A stateless session beans find an entity (= make it managed) and do the following tests:

    a) If i do NOT call the getter of the BLOB field from the managed entity, the prePersist() will not called, means, the entity will not updated. (Correct behavior)
    b) If i call the getter of the BLOB (LOB) field from a manged entity, hibernate will update the managed entity in the database (and the version field increments). INCORRECT behavior !


Why does hibernate update the entity if i yust call the getter of the BLOB field ? Could somebody help me to track down this problem ? Does i miss something ?

Code:
@Entity
public class SCXMLExecutorValue implements Serializable {

   @Lob
   @Column(length = 1000000)
   private Serializable scxmlExecutor;

   @Version
   @Column(name = "OPTLOCK")
   private Long version;

   public SCXMLExecutor getScxmlExecutor() {
      return (SCXMLExecutor) scxmlExecutor;
   }

   public void setScxmlExecutor(SCXMLExecutor scxmlExecutor) {
      this.scxmlExecutor = scxmlExecutor;
   }

   @PostPersist
   public void postPersist() {
      Logger log = Logger.getLogger(SCXMLExecutor.class);
      log.info("postPersist(): scxmlExecutorId: " + id);
   }

      ... other setter and getter

}


Versions i use:
Code:
hibernate-entitymanager   3.4.0.GA
hibernate-annotations    3.4.0.GA
hibernate-commons-annotations    3.1.0.GA
hibernate-core by hibernate   3.3.0.SP1


Top
 Profile  
 
 Post subject: BLOB fields always dirty after calling getter ?
PostPosted: Tue Sep 23, 2008 3:33 am 
Newbie

Joined: Sat Sep 20, 2008 3:10 pm
Posts: 2
Hi,

i tried the same tests with toplink and glassfish - and it works
correctly.

I also tried to define the "Serializable" field as a byte[] array (converting the Serializable myself to bytearray) - and
it also works (with hibernate)

Therefore, hibernate must have a bug ...

Can somebody confirm this behavior ?

regards
Danny


Top
 Profile  
 
 Post subject: Re: BLOB fields always dirty after calling getter ?
PostPosted: Mon Jan 04, 2010 8:52 am 
Newbie

Joined: Mon Jan 04, 2010 8:38 am
Posts: 1
Yep - I have exactly the same problem - for some reason the DefaultFlushEntityEventListener.dirtyCheck() has a new Blob instance than that which was used to hydrate the object in the first place. AbstractEntityPersister

(. Ive no idea why this happens but it will happen in all 'managed/txnl' contexts)

You could try and use a dirty check interceptor and ignore any LOB types


Top
 Profile  
 
 Post subject: Re: BLOB fields always dirty after calling getter ?
PostPosted: Wed Feb 03, 2010 6:43 pm 
Newbie

Joined: Thu Nov 05, 2009 11:31 am
Posts: 8
I have a similar problem. In one table there is a id column, an epoch column and a blob (byte[]) column. It appear that only sometimes does a change to the blob column get picked up. The epoch column does get picked up but not the byte[]/blob. Perhaps making matters more difficult is the contents of the attribute are compressed. It is not clear to me how Hibernate knows that field is dirty. The column is persisted on the original and in some cases but not consistently.

Can anyone else confirm this behavior?

Thanks,

Walt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.