users@glassfish.java.net

Hibernate, Entity wih LOB fields -> dirty after calling getter ?

From: <glassfish_at_javadesktop.org>
Date: Sat, 20 Sep 2008 12:58:07 PDT

Hi,

i use hibernate as the persistence provider in the current glassfish (9.1_02 (build b04-fcs). Problem: Hibernate/Glassfish does modify a managed 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/glassfish will update the managed entity in the database (and the version field increments). INCORRECT behavior !

Why does hibernate/glassfish 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 ?

@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:
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
[Message sent by forum member 'danny70437' (danny70437)]

http://forums.java.net/jive/thread.jspa?messageID=300547