persistence@glassfish.java.net

UPDATE after SELECT when executing em.find

From: Dies Koper <dies_at_jp.fujitsu.com>
Date: Tue, 22 Apr 2008 16:10:40 +0900

Hello,

I'm seeing an UPDATE after SELECT when executing em.find and I hope
someone can help me with it.
I want to use a @Version field with optimistic locking, but each time I
do a find the version field is incremented.

My entity has a field of type java.util.Properties, which I marked with
@Lob.
From my session bean I add some properties to it and persist it. That
goes fine.
In the next call I do an em.find in the session bean and return the
entity instance to the client. That's all. However, when I set the
toplink.logging.level.sql property to FINE I see that after the SELECT,
and UPDATE is executed too.

Why?
When I add only one property, I see no UPDATE.

I'm using GlassFish V2 UR1 with the Toplink Essentials that comes with
it, the database is Oracle and the table is created using
toplink.ddl-generation.

I'm using a JTA Entity Manager. Here's my entity's source:

import java.io.Serializable;
import java.util.Properties;

import javax.persistence.*;

@Entity
public class Target implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    private Long id=1L;

// @Version
    private int version;

    @Lob
    private Properties properties = new Properties();

    public Long getId() {
        return id;
    }

    public int getVersion() {
        return version;
    }

    public Properties getProperties() {
        return properties;
}

Thanks!
Dies