You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Norbert Rieger <nr...@lplusr.de> on 2009/02/13 10:53:44 UTC
Unnecessary Update - Entity not changed, but update statement exectuted
Hello,
when looking at my openEjb log file, I can see some updates I've never done
:-)
It looks like the entity is updated with the same values as stored already
in the database, the entity object was not modified.
This is what I do:
Bti ent ;
tx.begin () ;
ent = em.find (Bti.class, 200L) ;
tx.commit () ;
and here's the result from the log:
11437 PersistencePU TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
13330996> executing prepstmnt 31536808 SELECT t0.genDate, t0.modDate,
t0.bt_pkey, t0.descr, t0.fifo_order, t0.fifo_window, t0.ident, t0.type FROM
Bti t0 WHERE t0.pkey = ? [params=(long) 200]
...
Why is this update done ?
------------------==>
32719 PersistencePU TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
816382> executing prepstmnt 2665317 UPDATE Bti SET genDate = ?, modDate = ?,
bt_pkey = ?, descr = ?, fifo_order = ?, fifo_window = ?, ident = ?, type = ?
WHERE pkey = ? [params=(Timestamp) 2009-02-13 09:47:18.828, (Timestamp)
2009-02-13 09:59:06.375, (null) null, (null) null, (String) DESC, (int)
4711, (String) BTI-1, (String) TIMESTAMP, (long) 200]
------------------<==
Can someone point me to what I'm doing wrong ?
Thanks a lot for your help
Norbert
Here's the entity definition:
@NamedQueries
({
@NamedQuery(name="Bti.findAll", query="SELECT o FROM Bti o WHERE
o.btPkey = :btPkey"),
@NamedQuery(name="Bti.findByIdent", query="SELECT o FROM Bti o WHERE
o.btPkey = :btPkey and o.ident = :ident")
})
@Entity
@Table(uniqueConstraints=@UniqueConstraint(columnNames={"bt_pkey",
"ident"}))
public class Bti extends EntityBaseTimestamps implements Serializable
{
@Id
@TableGenerator (name="PK_GEN_BTI",
table="PK_GEN",
pkColumnName="PK_IDENT",
pkColumnValue="BTI.PKEY",
valueColumnName="PK_VALUE")
@GeneratedValue (strategy=GenerationType.TABLE,
generator="PK_GEN_BTI")
private Long pkey;
private String ident ;
@Column(name="bt_pkey")
private Long btPkey ;
private Long descr ;
@Enumerated(EnumType.STRING)
@Column(name="type",length=32)
BtiType_e type ;
@Enumerated(EnumType.STRING)
@Column(name="fifo_order",length=32)
BtiFiFoOrder_e fifoOrder ;
@Column(name="fifo_window")
Integer fifoWindow ;
public Bti()
{
}
}
EntityBaseTimestamps is a @MappedSuperclass holding modDate and genDate
fields.