users@glassfish.java.net

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

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Mon, 22 Sep 2008 16:05:11 -0700

Looks like a hibernate related issue. Try posting it in hibernate forums.

glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>