Von: 
  eclipselink-users-bounces@xxxxxxxxxxx 
  [mailto:eclipselink-users-bounces@xxxxxxxxxxx] Im Auftrag von Andrei 
  Ilitchev
Gesendet: Dienstag, 11. August 2009 19:49
An: 
  EclipseLink User Discussions
Betreff: Re: [eclipselink-users] No 
  OptimisticLocking Exception incombination with ReturnInsert and/or 
  ReturnUpdate
  
   
  
  ReturningPolicy cannot be 
  used with OptimisticLocking.
 
  
  Eclipselink throws 
  OptimisticLockException if UPDATE returns 0 (number of updated 
  rows).
 
  
  Unfortunately that doesn't 
  work with Oracle anonymous blocks or stored procedures: BEGIN ... END; always 
  returns one.
 
  
  
  Please log enhancement 
  request.
 
  
  
  In returning case currently 
  no update is performed on the db, but no PessimisticLockException is thrown, 
  too
 
  
  Note that in case no update 
  was performed all the returned values are nulls (or default values for 
  primitive types).
 
  
  To workaround handle 
  outputParametersDetected and raise OptimisticLockException yourself in case 
  all returned values are null.
 
  
  
  ----- Original Message ----- 
  
  
  
  
  Sent: Tuesday, August 11, 
  2009 2:29 AM
 
  
  Subject: AW: 
  [eclipselink-users] No OptimisticLocking Exception incombination with 
  ReturnInsert and/or ReturnUpdate
  
  
  So far so good but.
If 
  there are other changes going on at the Database between first load and Update 
  -> trying to update data from an old state. There is no 
  OptimisticLockingException to.
1. JavaApp loads the Date by 
  select
2. Update occurs on the Database by an PL/SQL-Job or something 
  else
3. JavaApp do an Update with all the old values in the where clause to 
  detect an OprimisticLocking
4. because of the changed Data at the Database 
  the Update doesn't affect any columns and the Returnvalues of the 
  ReturnInsert/ReturnUpdate Fields are mapped to null --> But NO 
  OptimisticLockingException <-- although there is one!
Log with 
  ReturnInsert/ReturnUbdate:
-----------------------------------
FEIN: 
  SELECT IDSYNDICAT, SYNNO, SYNNOM, UTILISATEUR, TEMPS, SYN_CODESEKTORLBE, 
  SYN_DATEBEGINN, SYN_DATEENDE, SYN_INSCHRIFT, CRE_DAT, CRE_KURZZ, IDCANTON, 
  IDDISTRICT, SYN_FRUEHJAHRSVERSAND_ID, SYN_VZGRECHTSFORM_ID FROM 
  GESTHO.SYNDICAT WHERE (SYNNO = ?)
bind => [152]
<- skip logs 
  till update ->
FEIN: BEGIN UPDATE GESTHO.SYNDICAT SET IDCANTON = ? 
  WHERE ((IDSYNDICAT = ?) AND ((((((((((((((SYNNO = ?) AND (SYNNOM = ?)) AND 
  (UTILISATEUR = ?)) AND (TEMPS = ?)) AND (SYN_CODESEKTORLBE = ?)) AND 
  (SYN_DATEBEGINN = ?)) AND (SYN_DATEENDE IS NULL)) AND (SYN_INSCHRIFT = ?)) AND 
  (CRE_DAT = ?)) AND (CRE_KURZZ = ?)) AND (IDCANTON = ?)) AND (IDDISTRICT = ?)) 
  AND (SYN_FRUEHJAHRSVERSAND_ID = ?)) AND (SYN_VZGRECHTSFORM_ID = ?))) RETURNING 
  CRE_KURZZ, UTILISATEUR, CRE_DAT, TEMPS INTO ?, ?, ?, ?; END;
bind => 
  [25, 152, 152, CHAM, BM, 2009-08-11 08:02:47.0, 2, 1907-01-01 00:00:00.0, 
  CHAM, 2001-08-19 00:00:00.0, INIT, 9, 6, 1896, 1686, => CRE_KURZZ, => 
  UTILISATEUR, => CRE_DAT, => TEMPS]
AM FEINSTEN: Assign return row 
  DatabaseRecord(
GESTHO.SYNDICAT.CRE_KURZZ => 
  INIT
GESTHO.SYNDICAT.UTILISATEUR => BM
GESTHO.SYNDICAT.CRE_DAT => 
  2001-08-19 00:00:00.0
GESTHO.SYNDICAT.TEMPS => 2009-08-11 
  08:16:17.0)
<- skip logs till update doing update on the db by 
  sqldeveloper in the meanwhile (SYNNOM='CHA') ->
FEIN: BEGIN UPDATE 
  GESTHO.SYNDICAT SET IDCANTON = ? WHERE ((IDSYNDICAT = ?) AND 
  ((((((((((((((SYNNO = ?) AND (SYNNOM = ?)) AND (UTILISATEUR = ?)) AND (TEMPS = 
  ?)) AND (SYN_CODESEKTORLBE = ?)) AND (SYN_DATEBEGINN = ?)) AND (SYN_DATEENDE 
  IS NULL)) AND (SYN_INSCHRIFT = ?)) AND (CRE_DAT = ?)) AND (CRE_KURZZ = ?)) AND 
  (IDCANTON = ?)) AND (IDDISTRICT = ?)) AND (SYN_FRUEHJAHRSVERSAND_ID = ?)) AND 
  (SYN_VZGRECHTSFORM_ID = ?))) RETURNING CRE_KURZZ, UTILISATEUR, CRE_DAT, TEMPS 
  INTO ?, ?, ?, ?; END;
bind => [9, 152, 152, CHAM, BM, 2009-08-11 
  08:16:17.0, 2, 1907-01-01 00:00:00.0, CHAM, 2001-08-19 00:00:00.0, INIT, 25, 
  6, 1896, 1686, => CRE_KURZZ, => UTILISATEUR, => CRE_DAT, => 
  TEMPS]
AM FEINSTEN: Assign return row 
  DatabaseRecord(
GESTHO.SYNDICAT.CRE_KURZZ => 
  null
GESTHO.SYNDICAT.UTILISATEUR => null
GESTHO.SYNDICAT.CRE_DAT 
  => null
GESTHO.SYNDICAT.TEMPS => null)
Log without 
  ReturnInsert/ReturnUpdate:
--------------------------------------
FEIN: 
  SELECT IDSYNDICAT, SYNNO, SYNNOM, UTILISATEUR, TEMPS, SYN_CODESEKTORLBE, 
  SYN_DATEBEGINN, SYN_DATEENDE, SYN_INSCHRIFT, CRE_DAT, CRE_KURZZ, IDCANTON, 
  IDDISTRICT, SYN_FRUEHJAHRSVERSAND_ID, SYN_VZGRECHTSFORM_ID FROM 
  GESTHO.SYNDICAT WHERE (SYNNO = ?)
bind => [152]
<- skip logs 
  till update ->
FEIN: UPDATE GESTHO.SYNDICAT SET IDCANTON = ? WHERE 
  ((IDSYNDICAT = ?) AND ((((((((((((((SYNNO = ?) AND (SYNNOM = ?)) AND 
  (UTILISATEUR = ?)) AND (TEMPS = ?)) AND (SYN_CODESEKTORLBE = ?)) AND 
  (SYN_DATEBEGINN = ?)) AND (SYN_DATEENDE IS NULL)) AND (SYN_INSCHRIFT = ?)) AND 
  (CRE_DAT = ?)) AND (CRE_KURZZ = ?)) AND (IDCANTON = ?)) AND (IDDISTRICT = ?)) 
  AND (SYN_FRUEHJAHRSVERSAND_ID = ?)) AND (SYN_VZGRECHTSFORM_ID = ?)))
bind 
  => [25, 152, 152, CHAM, BM, 2009-08-11 07:53:18.0, 2, 1907-01-01 
  00:00:00.0, CHAM, 2001-08-19 00:00:00.0, INIT, 9, 6, 1896, 1686]
<- 
  skip logs till update doing update on the db by sqldeveloper in the meanwhile 
  (SYNNOM='CHA') ->
FEIN: UPDATE GESTHO.SYNDICAT SET IDCANTON = ? 
  WHERE ((IDSYNDICAT = ?) AND ((((((((((((((SYNNO = ?) AND (SYNNOM = ?)) AND 
  (UTILISATEUR = ?)) AND (TEMPS = ?)) AND (SYN_CODESEKTORLBE = ?)) AND 
  (SYN_DATEBEGINN = ?)) AND (SYN_DATEENDE IS NULL)) AND (SYN_INSCHRIFT = ?)) AND 
  (CRE_DAT = ?)) AND (CRE_KURZZ = ?)) AND (IDCANTON = ?)) AND (IDDISTRICT = ?)) 
  AND (SYN_FRUEHJAHRSVERSAND_ID = ?)) AND (SYN_VZGRECHTSFORM_ID = ?)))
bind 
  => [9, 152, 152, CHAM, BM, 2009-08-11 07:53:56.0, 2, 1907-01-01 00:00:00.0, 
  CHAM, 2001-08-19 00:00:00.0, INIT, 25, 6, 1896, 1686]
WARNUNG: Local 
  Exception Stack: 
Exception [EclipseLink-5006] (Eclipse Persistence 
  Services - 1.0.1 (Build 20080905)): 
  org.eclipse.persistence.exceptions.OptimisticLockException
Exception 
  Description: The object 
  [ch.braunvieh.argus_core.db.argus.entity.Syndicat[idsyndicat=152]] cannot be 
  updated because it has changed or been deleted since it was last read. 
  
Class> ch.braunvieh.argus.association.db.Association Primary Key> 
  [152]
> -----Ursprüngliche Nachricht-----
> Von: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-
> bounces@xxxxxxxxxxx] Im Auftrag von Andrei Ilitchev
> Gesendet: 
  Montag, 10. August 2009 16:49
> An: EclipseLink User Discussions
> 
  Betreff: Re: [eclipselink-users] No OptimisticLocking Exception in
> 
  combination with ReturnInsert and/or ReturnUpdate
> 
> That sounds 
  correct:
> 
> Without return after the first update the states of 
  the object in the
> cache
> (Java app.) and in the db differ 
  (because of the trigger);
> with return however the db value created by 
  the trigger is returned
> back to
> the Java app., therefore the 
  states of object in the cache and the db
> are
> the same - hence 
  no OptimisticLockException.
> 
> ----- Original Message 
  -----
> From: <martin.berner@xxxxxxxxxxxx>
> To: "EclipseLink User Discussions" 
  <eclipselink-users@xxxxxxxxxxx>
> Sent: Monday, August 10, 2009 4:23 
  AM
> Subject: [eclipselink-users] No OptimisticLocking Exception 
  in
> combination
> with ReturnInsert and/or ReturnUpdate
> 
  
> 
> Hy,
> I annotated an Entity with
> 
  @OptimisticLocking(type=OptimisticLockingType.ALL_COLUMNS) to get an
> 
  OptimisticLickingException in case of an Update with old Data. 
  Database
> is
> Oracle 10g. We have fields on the Table which are 
  Updated by Oracle
> Triggers
> on Update and Insert so I annotated 
  dies Fields by @ReturnInsert and
> @ReturnUpdate:
> 
  
>     @Basic(optional = 
  false)
>     @Column(name = "UTILISATEUR", nullable 
  = false, length = 10)
>     
  @ReturnInsert
>     
  @ReturnUpdate
>     private String mutSign;
> 
  
> If I perform a Update on that Entity without ReturnInsert and
> 
  ReturnUpdate,
> and try to perform another update on the same Entity I 
  get an
> OptimisticLockingException because The Fields have changed per 
  Trigger
> on
> the Database.
> 
> But with The 
  Annotation of ReturnInsert and ReturnUpdate I didn't get
> an
> 
  OptimisticLockingException even if there is one.
> The only Thing I see 
  in the Log is, that it assign null to the Fields
> annotated by 
  ReturnInsert and ReturnUpdate by Returnvalue in case of
> old
> 
  Data, bat no Exception.
> In Fact the column wouldn't be updated, which 
  is correct because of the
> generated WHERE - clause.
> 
> 
  Is it a Problem combining  OptimisticLocking with ReturnInsert 
  and/or
> ReturnUpdate or have I configured something wrong? Or is it 
  fixed in a
> newer
> Version of EL (I'm Using EL 1.0.1 distributed 
  by GlassfishV3prelude)
> 
> Thanks for any Help
> 
> 
  Berner Martin
> 
> 
  _______________________________________________
> eclipselink-users 
  mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 
  _______________________________________________
> eclipselink-users 
  mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users 
  mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users